~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to debian/grub-extras/915resolution/915resolution.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu.  Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed.  If it is, show the
    menu, otherwise boot immediately.  If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt.  Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
#define fprintf(stream,template,args...)        grub_printf(template, ## args)
72
72
#define strtol(x,y,z)                           grub_strtoul(x,y,z)
73
73
#define atoi(x)                                 grub_strtoul(x,NULL,10)
74
 
#define assert(x)                               0 /* FIXME */
 
74
#define assert(x)                               
75
75
#define memset                                  grub_memset
76
76
#define outl            grub_outl
77
77
#define outb            grub_outb
91
91
 
92
92
#define MODE_TABLE_OFFSET_845G 617
93
93
 
94
 
#define VERSION "0.5.3"
 
94
#define RES915_VERSION "0.5.3"
95
95
 
96
96
#define ATI_SIGNATURE1 "ATI MOBILITY RADEON"
97
97
#define ATI_SIGNATURE2 "ATI Technologies Inc"
98
98
#define NVIDIA_SIGNATURE "NVIDIA Corp"
99
99
#define INTEL_SIGNATURE "Intel Corp"
100
100
 
 
101
#define DEBUG 0
 
102
 
101
103
typedef unsigned char * address;
102
104
typedef unsigned char byte;
103
105
typedef unsigned short word;
212
214
} vbios_map;
213
215
 
214
216
 
215
 
cardinal get_chipset_id(void) {
 
217
static cardinal get_chipset_id(void) {
216
218
    outl(0x80000000, 0xcf8);
217
219
    return inl(0xcfc);
218
220
}
219
221
 
220
 
chipset_type get_chipset(cardinal id) {
 
222
static chipset_type get_chipset(cardinal id) {
221
223
    chipset_type type;
222
224
    
223
225
    switch (id) {
298
300
}
299
301
 
300
302
 
301
 
vbios_resolution_type1 * map_type1_resolution(vbios_map * map, word res) {
 
303
static vbios_resolution_type1 * map_type1_resolution(vbios_map * map, word res) {
302
304
    vbios_resolution_type1 * ptr = ((vbios_resolution_type1*)(map->bios_ptr + res)); 
303
305
    return ptr;
304
306
}
305
307
 
306
 
vbios_resolution_type2 * map_type2_resolution(vbios_map * map, word res) {
 
308
static vbios_resolution_type2 * map_type2_resolution(vbios_map * map, word res) {
307
309
    vbios_resolution_type2 * ptr = ((vbios_resolution_type2*)(map->bios_ptr + res)); 
308
310
    return ptr;
309
311
}
310
312
 
311
 
vbios_resolution_type3 * map_type3_resolution(vbios_map * map, word res) {
 
313
static vbios_resolution_type3 * map_type3_resolution(vbios_map * map, word res) {
312
314
    vbios_resolution_type3 * ptr = ((vbios_resolution_type3*)(map->bios_ptr + res)); 
313
315
    return ptr;
314
316
}
315
317
 
316
318
 
317
 
boolean detect_bios_type(vbios_map * map, boolean modeline, int entry_size) {
318
 
    int i;
 
319
static boolean detect_bios_type(vbios_map * map, int entry_size) {
 
320
    unsigned i;
319
321
    short int r1, r2;
320
322
    
321
323
    r1 = r2 = 32000;
337
339
}
338
340
 
339
341
 
340
 
void close_vbios(vbios_map * map);
341
 
 
342
 
 
343
 
vbios_map * open_vbios(chipset_type forced_chipset) {
 
342
static void close_vbios(vbios_map * map);
 
343
 
 
344
 
 
345
static vbios_map * open_vbios(chipset_type forced_chipset) {
344
346
    vbios_map * map = NEW(vbios_map);
345
347
    memset (map, 0, sizeof(vbios_map));
346
348
 
364
366
     *  Map the video bios to memory
365
367
     */
366
368
 
367
 
    map->bios_ptr=(char*)VBIOS_START;
 
369
    map->bios_ptr = (unsigned char *) VBIOS_START;
368
370
 
369
371
#if 0
370
372
    /*
466
468
     *  order of detection is important
467
469
     */
468
470
 
469
 
    if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type3))) {
 
471
    if (detect_bios_type(map, sizeof(vbios_modeline_type3))) {
470
472
        map->bios = BT_3;
471
473
    }
472
 
    else if (detect_bios_type(map, TRUE, sizeof(vbios_modeline_type2))) {
 
474
    else if (detect_bios_type(map, sizeof(vbios_modeline_type2))) {
473
475
        map->bios = BT_2;
474
476
    }
475
 
    else if (detect_bios_type(map, FALSE, sizeof(vbios_resolution_type1))) {
 
477
    else if (detect_bios_type(map, sizeof(vbios_resolution_type1))) {
476
478
        map->bios = BT_1;
477
479
    }
478
480
    else {
489
491
    return map;
490
492
}
491
493
 
492
 
void close_vbios(vbios_map * map) {
 
494
static void close_vbios(vbios_map * map) {
493
495
    assert(!map->unlocked);
494
496
 
495
497
    FREE(map);
496
498
}
497
499
 
498
 
void unlock_vbios(vbios_map * map) {
 
500
static void unlock_vbios(vbios_map * map) {
499
501
 
500
502
    assert(!map->unlocked);
501
503
        
545
547
#endif
546
548
}
547
549
 
548
 
void relock_vbios(vbios_map * map) {
 
550
static void relock_vbios(vbios_map * map) {
549
551
 
550
552
    assert(map->unlocked);
551
553
    map->unlocked = FALSE;
588
590
}
589
591
 
590
592
 
591
 
void list_modes(vbios_map *map, cardinal raw) {
 
593
static void list_modes(vbios_map *map, cardinal raw) {
592
594
    cardinal i, x, y;
593
595
 
594
596
    for (i=0; i < map->mode_table_size; i++) {
662
664
    *clock = (x + hbl) * vfreq / 1000;
663
665
}
664
666
 
665
 
void set_mode(vbios_map * map, cardinal mode, cardinal x, cardinal y, cardinal bp, cardinal htotal, cardinal vtotal) {
 
667
static void set_mode(vbios_map * map, cardinal mode, cardinal x, cardinal y, cardinal bp, cardinal htotal, cardinal vtotal) {
666
668
    int xprev, yprev;
667
669
    cardinal i, j;
668
670
 
763
765
    }
764
766
}   
765
767
 
766
 
void display_map_info(vbios_map * map) {
 
768
static void display_map_info(vbios_map * map) {
767
769
    printf("Chipset: %s\n", chipset_type_names[map->chipset]);
768
770
    printf("BIOS: %s\n", bios_type_names[map->bios]);
769
771
 
772
774
}
773
775
 
774
776
 
775
 
int parse_args(int argc, char *argv[], chipset_type *forced_chipset, cardinal *list, cardinal *mode, cardinal *x, cardinal *y, cardinal *bp, cardinal *raw, cardinal *htotal, cardinal *vtotal) {
 
777
static int parse_args(cardinal argc, char *argv[], chipset_type *forced_chipset, cardinal *list, cardinal *mode, cardinal *x, cardinal *y, cardinal *bp, cardinal *raw, cardinal *htotal, cardinal *vtotal) {
776
778
    cardinal index = 0;
777
779
 
778
780
    *list = *mode = *x = *y = *raw = *htotal = *vtotal = 0;
 
781
    *bp = 0;
779
782
 
780
783
    *forced_chipset = CT_UNKWN;
781
784
    
897
900
    return 0;
898
901
}
899
902
 
900
 
static void usage() {
 
903
static void usage(void) {
901
904
    printf("Usage: 915resolution [-c chipset] [-l] [mode X Y] [bits/pixel] [htotal] [vtotal]\n");
902
905
    printf("  Set the resolution to XxY for a video mode\n");
903
906
    printf("  Bits per pixel are optional.  htotal/vtotal settings are additionally optional.\n");
907
910
    printf("    -r display the modes found in the video BIOS in raw mode (THIS IS USED FOR DEBUG PURPOSES)\n");
908
911
}
909
912
 
910
 
int main (int argc, char *argv[])
 
913
static int main (int argc, char *argv[])
911
914
{
912
915
    vbios_map * map;
913
916
    cardinal list, mode, x, y, bp, raw, htotal, vtotal;
914
917
    chipset_type forced_chipset;
915
918
    
916
 
    printf("Intel 800/900 Series VBIOS Hack : version %s\n\n", VERSION);
 
919
    printf("Intel 800/900 Series VBIOS Hack : version %s\n\n", RES915_VERSION);
917
920
 
918
921
    if (parse_args(argc, argv, &forced_chipset, &list, &mode, &x, &y, &bp, &raw, &htotal, &vtotal) == -1) {
919
922
        usage();
953
956
 
954
957
 
955
958
static grub_err_t
956
 
grub_cmd_915resolution (struct grub_arg_list *state __attribute__ ((unused)), int argc, char *argv[])
 
959
grub_cmd_915resolution (grub_command_t cmd __attribute__ ((unused)), 
 
960
                        int argc, char *argv[])
957
961
{
958
962
  return main (argc, argv);
959
963
}
960
964
 
 
965
static grub_command_t cmd;
 
966
 
961
967
GRUB_MOD_INIT(915resolution)
962
968
{
963
 
  (void)mod;                    /* To stop warning. */
964
 
  grub_register_extcmd ("915resolution", grub_cmd_915resolution, GRUB_COMMAND_FLAG_BOTH,
965
 
                         "915resolution", "Intel VBE editor", 0);
 
969
  cmd = grub_register_command ("915resolution", grub_cmd_915resolution,
 
970
                               "915resolution", "Intel VBE editor");
966
971
}
967
972
 
968
973
GRUB_MOD_FINI(915resolution)
969
974
{
970
 
  grub_unregister_command ("915resolution");
 
975
  grub_unregister_command (cmd);
971
976
}