Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 80693 | Differences between
and this patch

Collapse All | Expand All

(-)grub-0.96.orig/docs/grub.texi (+10 lines)
Lines 2118-2123 Link Here
2118
* default::                     Set the default entry
2118
* default::                     Set the default entry
2119
* fallback::                    Set the fallback entry
2119
* fallback::                    Set the fallback entry
2120
* hiddenmenu::                  Hide the menu interface
2120
* hiddenmenu::                  Hide the menu interface
2121
* gfxmenu::                     Use graphical menu interface
2121
* timeout::                     Set the timeout
2122
* timeout::                     Set the timeout
2122
* title::                       Start a menu entry
2123
* title::                       Start a menu entry
2123
@end menu
2124
@end menu
Lines 2150-2155 Link Here
2150
@end deffn
2151
@end deffn
2151
2152
2152
2153
2154
@node gfxmenu
2155
@subsection gfxmenu
2156
2157
@deffn Command gfxmenu file
2158
Use the graphical menu interface. The graphics data are taken from
2159
@var{file} and must be created using 'mkbootmsg' from the gfxboot package.
2160
@end deffn
2161
2162
2153
@node hiddenmenu
2163
@node hiddenmenu
2154
@subsection hiddenmenu
2164
@subsection hiddenmenu
2155
2165
(-)grub-0.96.orig/grub/asmstub.c (+26 lines)
Lines 478-483 Link Here
478
  return 0;
478
  return 0;
479
}
479
}
480
480
481
/* graphical menu functions .  */
482
int
483
gfx_init (gfx_data_t *gfx_data)
484
{
485
  return 0;
486
}
487
488
int
489
gfx_done (gfx_data_t *gfx_data)
490
{
491
  return 0;
492
}
493
494
int
495
gfx_input (gfx_data_t *gfx_data, int *menu_entry)
496
{
497
  return 0;
498
}
499
500
int
501
gfx_setup_menu (gfx_data_t *gfx_data)
502
{
503
  return 0;
504
}
505
506
481
/* low-level timing info */
507
/* low-level timing info */
482
int
508
int
483
getrtsecs (void)
509
getrtsecs (void)
(-)grub-0.96.orig/stage2/asm.S (+288 lines)
Lines 1610-1615 Link Here
1610
	popl	%ebp
1610
	popl	%ebp
1611
	ret
1611
	ret
1612
1612
1613
1614
/*
1615
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1616
 *
1617
 * graphical menu functions
1618
 *
1619
 */
1620
1621
/*
1622
 * int gfx_init (gfx_data_t *gfx_data)
1623
 *
1624
 * init gfx things
1625
 *
1626
 * return vales:
1627
 *   0: ok
1628
 *   1: failed
1629
 *   sets gfx_data->ok
1630
 */
1631
1632
ENTRY(gfx_init)
1633
	pushl	%ebp
1634
	movl	%esp, %ebp
1635
	
1636
	pushl	%edi
1637
	pushl	%esi
1638
	pushl	%ebx
1639
1640
	movl	8(%ebp),%edx
1641
	movl	%edx,%edi
1642
	andl	$0xf,%edi
1643
	shrl	$4,%edx
1644
1645
	pushl	%ebp
1646
1647
	call	EXT_C(prot_to_real)
1648
	.code16
1649
1650
	pushw	%ds
1651
1652
	movw	%dx,%ds
1653
	shll	$4,%edx
1654
	leal	gfx_ofs_sys_cfg(%di),%esi
1655
	movl	gfx_ofs_mem_start(%di),%eax
1656
	movl	gfx_ofs_mem_cur(%di),%ebx
1657
	movl	gfx_ofs_mem_max(%di),%ecx
1658
	movw	%ds,%dx
1659
1660
	lcall	*gfx_ofs_jmp_table + 4 * 0 (%di)
1661
1662
	movl	$0,%ebx
1663
	adcl	$0,%ebx
1664
1665
	popw	%ds
1666
1667
	DATA32	call	EXT_C(real_to_prot)
1668
	.code32
1669
1670
	popl	%ebp
1671
1672
	movl	%ebx,%eax
1673
	negl	%ebx
1674
	incl	%ebx
1675
	movl	8(%ebp),%edx
1676
	movl	%ebx,gfx_ofs_ok(%edx)
1677
1678
	popl	%ebx
1679
	popl	%esi
1680
	popl	%edi
1681
1682
	popl	%ebp
1683
	ret
1684
1685
1686
/*
1687
 * int gfx_done (gfx_data_t *gfx_data)
1688
 *
1689
 * shut down gfx things
1690
 *
1691
 * return vales:
1692
 *   always 0
1693
 *   sets gfx_data->ok
1694
 */
1695
1696
ENTRY(gfx_done)
1697
	pushl	%ebp
1698
	movl	%esp, %ebp
1699
	
1700
	pushl	%edi
1701
	pushl	%esi
1702
	pushl	%ebx
1703
1704
	movl	8(%ebp),%edx
1705
	movl	%edx,%ebx
1706
	andl	$0xf,%ebx
1707
	shrl	$4,%edx
1708
1709
	pushl	%ebp
1710
1711
	call	EXT_C(prot_to_real)
1712
	.code16
1713
1714
	pushw	%ds
1715
1716
	movw	%dx,%ds
1717
1718
	lcall	*gfx_ofs_jmp_table + 4 * 1 (%bx)
1719
1720
	popw	%ds
1721
1722
	DATA32	call	EXT_C(real_to_prot)
1723
	.code32
1724
1725
	popl	%ebp
1726
1727
	xorl	%eax,%eax
1728
	movl	8(%ebp),%edx
1729
	movl	%eax,gfx_ofs_ok(%edx)
1730
1731
	popl	%ebx
1732
	popl	%esi
1733
	popl	%edi
1734
1735
	popl	%ebp
1736
	ret
1737
1738
1739
/*
1740
 * int gfx_input (gfx_data_t *gfx_data, int *menu_entry)
1741
 *
1742
 * let user enter a command line
1743
 *
1744
 * uses gfx_data->cmdline as buffer
1745
 *
1746
 * return values:
1747
 *   1: abort
1748
 *   2: boot
1749
 *   menu_entry: selected entry
1750
 */
1751
1752
ENTRY(gfx_input)
1753
	pushl	%ebp
1754
	movl	%esp, %ebp
1755
	
1756
	pushl	%edi
1757
	pushl	%esi
1758
	pushl	%ebx
1759
1760
	movl	8(%ebp),%edx
1761
	movl	%edx,%ebx
1762
	andl	$0xf,%ebx
1763
	shrl	$4,%edx
1764
1765
	pushl	%ebp
1766
1767
	call	EXT_C(prot_to_real)
1768
	.code16
1769
1770
	pushw	%ds
1771
1772
	movw	%dx,%ds
1773
	shll	$4,%edx
1774
	movl	gfx_ofs_cmdline(%bx),%edi
1775
	subl	%edx,%edi
1776
	movw	gfx_ofs_cmdline_len(%bx),%cx
1777
	movw	gfx_ofs_timeout(%bx),%ax
1778
	imulw	$18,%ax
1779
1780
	pushl	%ebp
1781
	lcall	*gfx_ofs_jmp_table + 4 * 2 (%bx)
1782
	popl	%ebp
1783
	movl	%eax,%ecx
1784
1785
	popw	%ds
1786
1787
	DATA32	call	EXT_C(real_to_prot)
1788
	.code32
1789
1790
	popl	%ebp
1791
1792
	movl	12(%ebp),%edx
1793
	movl	%ebx,(%edx)
1794
1795
	movl	%ecx,%eax
1796
1797
	popl	%ebx
1798
	popl	%esi
1799
	popl	%edi
1800
1801
	popl	%ebp
1802
	ret
1803
1804
1805
/*
1806
 * int gfx_setup_menu (gfx_data_t *gfx_data)
1807
 *
1808
 * draw boot menu
1809
 *
1810
 * return values:
1811
 *   always 0
1812
 */
1813
1814
/* menu entry descriptor */
1815
#define menu_entries		0
1816
#define menu_default		2	/* seg:ofs */
1817
#define menu_ent_list		6	/* seg:ofs */
1818
#define menu_ent_size		10
1819
#define menu_arg_list		12	/* seg:ofs */
1820
#define menu_arg_size		16
1821
#define sizeof_menu_desc	18
1822
1823
ENTRY(gfx_setup_menu)
1824
	pushl	%ebp
1825
	movl	%esp, %ebp
1826
	
1827
	pushl	%edi
1828
	pushl	%esi
1829
	pushl	%ebx
1830
1831
	movl	8(%ebp),%edx
1832
	movl	%edx,%ebx
1833
	andl	$0xf,%ebx
1834
	shrl	$4,%edx
1835
1836
	call	EXT_C(prot_to_real)
1837
	.code16
1838
1839
	pushw	%ds
1840
1841
	movw	%dx,%ds
1842
	shll	$4,%edx
1843
1844
	subw	$sizeof_menu_desc,%sp
1845
	movw	%sp,%bp
1846
1847
	movl	gfx_ofs_menu_entries(%bx),%eax
1848
	movw	%ax,menu_entries(%bp)
1849
1850
	movl	gfx_ofs_menu_default_entry(%bx),%eax
1851
	subl	%edx,%eax
1852
	movw	%ax,menu_default(%bp)
1853
	movw	%ds,menu_default+2(%bp)
1854
1855
	movl	gfx_ofs_menu_list(%bx),%eax
1856
	subl	%edx,%eax
1857
	movw	%ax,menu_ent_list(%bp)
1858
	movw	%ds,menu_ent_list+2(%bp)
1859
1860
	movl	gfx_ofs_menu_entry_len(%bx),%eax
1861
	movw	%ax,menu_ent_size(%bp)
1862
1863
	movl	gfx_ofs_args_list(%bx),%eax
1864
	subl	%edx,%eax
1865
	movw	%ax,menu_arg_list(%bp)
1866
	movw	%ds,menu_arg_list+2(%bp)
1867
1868
	movl	gfx_ofs_args_entry_len(%bx),%eax
1869
	movw	%ax,menu_arg_size(%bp)
1870
1871
	movw	%bp,%si
1872
	pushw	%ss
1873
	popw	%es
1874
	
1875
	lcall	%ds: *gfx_ofs_jmp_table + 4 * 3 (%bx)
1876
1877
	addw	$sizeof_menu_desc,%sp
1878
1879
	popw	%ds
1880
1881
	DATA32	call	EXT_C(real_to_prot)
1882
	.code32
1883
1884
	xorl	%eax,%eax
1885
1886
	popl	%ebx
1887
	popl	%esi
1888
	popl	%edi
1889
1890
	popl	%ebp
1891
	ret
1892
1893
1894
/*
1895
 *
1896
 * end graphics stuff
1897
 *
1898
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1899
 */
1900
1613
		
1901
		
1614
/*
1902
/*
1615
 * gateA20(int linear)
1903
 * gateA20(int linear)
(-)grub-0.96.orig/stage2/builtins.c (+23 lines)
Lines 63-68 Link Here
63
int fallback_entries[MAX_FALLBACK_ENTRIES];
63
int fallback_entries[MAX_FALLBACK_ENTRIES];
64
/* The number of current entry.  */
64
/* The number of current entry.  */
65
int current_entryno;
65
int current_entryno;
66
/* graphics file */
67
char graphics_file[64];
66
/* The address for Multiboot command-line buffer.  */
68
/* The address for Multiboot command-line buffer.  */
67
static char *mb_cmdline;
69
static char *mb_cmdline;
68
/* The password.  */
70
/* The password.  */
Lines 1327-1332 Link Here
1327
};
1329
};
1328
1330
1329
1331
1332
/* graphics */
1333
static int
1334
gfxmenu_func (char *arg, int flags)
1335
{
1336
  memmove(graphics_file, arg, sizeof graphics_file - 1);
1337
  graphics_file[sizeof graphics_file - 1] = 0;
1338
1339
  return 0;
1340
}
1341
1342
static struct builtin builtin_gfxmenu =
1343
{
1344
  "gfxmenu",
1345
  gfxmenu_func,
1346
  BUILTIN_MENU | BUILTIN_HELP_LIST,
1347
  "gfxmenu FILE",
1348
  "Use the graphical menu from FILE."
1349
};
1350
1351
1330
/* geometry */
1352
/* geometry */
1331
static int
1353
static int
1332
geometry_func (char *arg, int flags)
1354
geometry_func (char *arg, int flags)
Lines 4811-4816 Link Here
4811
  &builtin_find,
4833
  &builtin_find,
4812
  &builtin_fstest,
4834
  &builtin_fstest,
4813
  &builtin_geometry,
4835
  &builtin_geometry,
4836
  &builtin_gfxmenu,
4814
  &builtin_halt,
4837
  &builtin_halt,
4815
  &builtin_help,
4838
  &builtin_help,
4816
  &builtin_hiddenmenu,
4839
  &builtin_hiddenmenu,
(-)grub-0.96.orig/stage2/shared.h (+52 lines)
Lines 374-379 Link Here
374
#endif /* WITHOUT_LIBC_STUBS */
374
#endif /* WITHOUT_LIBC_STUBS */
375
375
376
376
377
/* see typedef gfx_data_t below */
378
#define gfx_ofs_ok			0x00
379
#define gfx_ofs_mem_start		0x04
380
#define gfx_ofs_mem_cur			0x08
381
#define gfx_ofs_mem_max			0x0c
382
#define gfx_ofs_code_seg		0x10
383
#define gfx_ofs_jmp_table		0x14
384
#define gfx_ofs_sys_cfg			0x44
385
#define gfx_ofs_cmdline			0x4c
386
#define gfx_ofs_cmdline_len		0x50
387
#define gfx_ofs_menu_list		0x54
388
#define gfx_ofs_menu_default_entry	0x58
389
#define gfx_ofs_menu_entries		0x5c
390
#define gfx_ofs_menu_entry_len		0x60
391
#define gfx_ofs_args_list		0x64
392
#define gfx_ofs_args_entry_len		0x68
393
#define gfx_ofs_timeout			0x6c
394
395
377
#ifndef ASM_FILE
396
#ifndef ASM_FILE
378
/*
397
/*
379
 *  Below this should be ONLY defines and other constructs for C code.
398
 *  Below this should be ONLY defines and other constructs for C code.
Lines 595-600 Link Here
595
extern int default_entry;
614
extern int default_entry;
596
extern int current_entryno;
615
extern int current_entryno;
597
616
617
618
/*
619
 * graphics menu stuff
620
 *
621
 * Note: gfx_data and all data referred to in it must lie within a 64k area.
622
 */
623
typedef struct {
624
  unsigned ok;			/* set while we're in graphics mode */
625
  unsigned mem_start, mem_cur, mem_max;
626
  unsigned code_seg;		/* code segment of binary graphics code */
627
  unsigned jmp_table[12];	/* link to graphics functions */
628
  unsigned char sys_cfg[8];	/* sys_cfg[0]: identifies boot loader (grub == 2) */
629
  char *cmdline;		/* command line returned by gfx_input() */
630
  unsigned cmdline_len;		/* length of the above */
631
  char *menu_list;		/* list of menu entries, each of fixed length (menu_entry_len) */
632
  char *menu_default_entry;	/* the default entry */
633
  unsigned menu_entries;	/* number of entries in menu_list */
634
  unsigned menu_entry_len;	/* one entry */
635
  char *args_list;		/* same structure as menu_list, menu_entries entries */
636
  unsigned args_entry_len;	/* one entry */
637
  unsigned timeout;		/* in seconds (0: no timeout) */
638
} __attribute__ ((packed)) gfx_data_t;
639
640
extern gfx_data_t *graphics_data;
641
642
/* pointer to graphics image data */
643
extern char graphics_file[64];
644
645
int gfx_init(gfx_data_t *gfx_data);
646
int gfx_done(gfx_data_t *gfx_data);
647
int gfx_input(gfx_data_t *gfx_data, int *menu_entry);
648
int gfx_setup_menu(gfx_data_t *gfx_data);
649
598
/* The constants for password types.  */
650
/* The constants for password types.  */
599
typedef enum
651
typedef enum
600
{
652
{
(-)grub-0.96.orig/stage2/stage2.c (-3 / +349 lines)
Lines 22-27 Link Here
22
22
23
grub_jmp_buf restart_env;
23
grub_jmp_buf restart_env;
24
24
25
gfx_data_t *graphics_data;
26
25
#if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
27
#if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS)
26
28
27
# if defined(PRESET_MENU_STRING)
29
# if defined(PRESET_MENU_STRING)
Lines 310-315 Link Here
310
      
312
      
311
      if (! auth && password)
313
      if (! auth && password)
312
	{
314
	{
315
	  if (*graphics_file)
316
	    {
317
	      printf ("\
318
	WARNING: graphical menu doesn\'t work\
319
	in conjunction with the password feature\n" );
320
	    }
313
	  printf ("\
321
	  printf ("\
314
      Press enter to boot the selected OS or \'p\' to enter a\n\
322
      Press enter to boot the selected OS or \'p\' to enter a\n\
315
      password to unlock the next set of features.");
323
      password to unlock the next set of features.");
Lines 753-758 Link Here
753
}
761
}
754
762
755
763
764
765
/* for debugging */
766
static void hexdump(unsigned char *buf, unsigned len)
767
{
768
  int i, j = 0;
769
  char s[17];
770
  unsigned addr = (unsigned) buf;
771
772
  s[16] = 0;
773
  while(len--) {
774
    i = buf[j];
775
    i = i & 0xff;
776
    s[j & 15] = (i >= 0x20 && i <= 0x7e) ? i : '.';
777
    if(!(j & 15)) {
778
      printf("%x  ", j + addr);
779
    }
780
    if(!(j & 7) && (j & 15)) printf(" ");
781
    /* stupid grub_printf */
782
    printf("%x", (i >> 4) & 0x0f);
783
    printf("%x ", i & 0x0f);
784
    if(!(++j & 15)) {
785
      printf(" %s\n", s);
786
    }
787
  }
788
789
  if(j & 15) {
790
    s[j & 15] = 0;
791
    if(!(j & 8)) printf(" ");
792
    i = 1 + 3 * (16 - (j & 15));
793
    while(i--) printf(" ");
794
    printf("%s\n", s);
795
  }
796
}
797
798
799
/*
800
 * Go through config entry and find kernel args, if any.
801
 */
802
static char *get_kernel_args(char *cfg)
803
{
804
  int j;
805
  char *s, *t = "";
806
807
  for(j = 0; ; j++) {
808
    s = get_entry(cfg, j, 0);
809
    if(!*s) break;
810
    if(!memcmp(s, "kernel", 6) && (s[6] == ' ' || s[6] == '\t')) {
811
      t = skip_to(0, s);
812
      if(*t) t = skip_to(0, t);
813
      break;
814
    }
815
  }
816
817
  return t;
818
}
819
820
821
/*
822
 * Leave that much space on the heap. Everything else goes to the graphics
823
 * functions.
824
 *
825
 * 0x2000 is _not_ enough
826
 */
827
#define MIN_HEAP_SIZE	0x4000
828
829
/* gfx code needs at least this much free memory */
830
#define MIN_GFX_FREE	0xc000
831
832
/*
833
 * Does normally not return.
834
 */
835
static void
836
run_graphics_menu (char *menu_entries, char *config_entries, int num_entries,
837
	  char *heap, int entryno)
838
{
839
  unsigned char *buf;
840
  unsigned buf_size, code_start;
841
  char *s, *t, *cfg, *new_config;
842
  char *saved_heap;
843
  int i, j, max_len;
844
  int selected_entry;
845
  gfx_data_t *gfx_data;
846
847
  /*
848
   * check gfx_data_t struct offsets for consistency; gcc will optimize away
849
   * the whole block
850
   */
851
852
  /* dummy function to make ld fail */
853
  {
854
    extern void wrong_struct_size(void);
855
    #define gfx_ofs_check(a) if(gfx_ofs_##a != (char *) &gfx_data->a - (char *) gfx_data) wrong_struct_size();
856
    gfx_ofs_check(ok);
857
    gfx_ofs_check(mem_start);
858
    gfx_ofs_check(mem_cur);
859
    gfx_ofs_check(mem_max);
860
    gfx_ofs_check(code_seg);
861
    gfx_ofs_check(jmp_table);
862
    gfx_ofs_check(sys_cfg);
863
    gfx_ofs_check(cmdline);
864
    gfx_ofs_check(cmdline_len);
865
    gfx_ofs_check(menu_list);
866
    gfx_ofs_check(menu_default_entry);
867
    gfx_ofs_check(menu_entries);
868
    gfx_ofs_check(menu_entry_len);
869
    gfx_ofs_check(args_list);
870
    gfx_ofs_check(args_entry_len);
871
    gfx_ofs_check(timeout);
872
    #undef gfx_ofs_check
873
  }
874
875
  if(!num_entries) return;
876
877
  graphics_data = gfx_data = (gfx_data_t *) heap;
878
  heap += sizeof *gfx_data;
879
  memset(gfx_data, 0, sizeof *gfx_data);
880
881
  gfx_data->sys_cfg[0] = 2;	/* bootloader: grub */
882
  gfx_data->timeout = grub_timeout >= 0 ? grub_timeout : 0;
883
884
885
  /* setup command line edit buffer */
886
887
  gfx_data->cmdline_len = 256;
888
889
  gfx_data->cmdline = heap;
890
  heap += gfx_data->cmdline_len;
891
  memset(gfx_data->cmdline, 0, gfx_data->cmdline_len);
892
893
894
  /* setup menu entries */
895
896
  for(i = max_len = 0; i < num_entries; i++) {
897
    j = strlen(get_entry(menu_entries, i, 0));
898
    if(j > max_len) max_len = j;
899
  }
900
901
  if(!max_len) return;
902
903
  gfx_data->menu_entry_len = max_len + 1;
904
  gfx_data->menu_entries = num_entries;
905
906
  gfx_data->menu_list = heap;
907
  heap += gfx_data->menu_entry_len * gfx_data->menu_entries;
908
909
  memset(gfx_data->menu_list, 0, gfx_data->menu_entry_len * gfx_data->menu_entries);
910
911
  for(i = 0; i < gfx_data->menu_entries; i++) {
912
    strcpy(gfx_data->menu_list + i * gfx_data->menu_entry_len, get_entry(menu_entries, i, 0));
913
  }
914
915
  gfx_data->menu_default_entry = gfx_data->menu_list + entryno * gfx_data->menu_entry_len;
916
917
918
  /* setup list of kernel args */
919
920
  for(i = max_len = 0; i < num_entries; i++) {
921
    s = get_kernel_args(get_entry(config_entries, i, 1));
922
    j = strlen(s);
923
    if(j > max_len) max_len = j;
924
  }
925
926
  gfx_data->args_entry_len = max_len + 1;
927
928
  gfx_data->args_list = heap;
929
  heap += gfx_data->args_entry_len * gfx_data->menu_entries;
930
931
  memset(gfx_data->args_list, 0, gfx_data->args_entry_len * gfx_data->menu_entries);
932
933
  for(i = 0; i < gfx_data->menu_entries; i++) {
934
    strcpy(gfx_data->args_list + i* gfx_data->args_entry_len, get_kernel_args(get_entry(config_entries, i, 1)));
935
  }
936
937
938
  /* go back here when we no longer need the graphics data */
939
  saved_heap = heap;
940
941
942
  /* get memory area to be used by graphics functions */
943
944
  buf = (unsigned char *) (((unsigned) heap + 0xf) & ~0xf);
945
946
  buf_size = (unsigned char *) &buf - buf - MIN_HEAP_SIZE;
947
  buf_size &= ~0xf;
948
949
  /* too small */
950
  if(buf_size < 0x10000) return;
951
952
  gfx_data->mem_start = (unsigned) buf;
953
  gfx_data->mem_max = gfx_data->mem_start + buf_size;
954
955
#if 0
956
  printf("graphics menu\n");
957
  printf(
958
    "heap = 0x%x, buf = 0x%x (0x%x bytes), graphics_file = %s\n",
959
    heap, gfx_data->mem_start, buf_size, graphics_file
960
  );
961
  getkey();
962
#endif
963
964
  heap += buf_size;
965
966
967
  /* read the file */
968
969
  if(!grub_open(graphics_file)) {
970
    printf("graphics file \"%s\" missing, press a key to continue...\n", graphics_file);
971
    getkey();
972
    return;
973
  }
974
975
  i = grub_read(buf, buf_size);
976
977
  grub_close();
978
979
  if(i <= 0) {
980
    printf("error reading \"%s\", press a key to continue...\n", graphics_file);
981
    getkey();
982
    return;
983
  }
984
985
  /* besides the file, we need some working memory, too */
986
  if(i + MIN_GFX_FREE >= buf_size) {
987
    printf("file \"%s\" too large, press a key to continue...\n", graphics_file);
988
    getkey();
989
    return;
990
  }
991
992
  gfx_data->mem_cur = gfx_data->mem_start + ((i + 3) & ~3);	/* align it */
993
994
  // printf("image: %d bytes (%d bytes left)\n", i, gfx_data->mem_max - gfx_data->mem_cur);
995
  // getkey();
996
997
  if(
998
    *(unsigned *) buf != 0x0b2d97f00 ||		/* magic id */
999
    buf[4] != 4 ||				/* version 4 */
1000
    !(code_start = *(unsigned *) (buf + 8)) ||
1001
    (code_start & 0xf)				/* check alignment */
1002
  ) {
1003
    printf("\"%s\" has wrong format, press a key to continue...\n", graphics_file);
1004
    getkey();
1005
    return;
1006
  }
1007
1008
1009
  /* init interface to graphics functions */
1010
1011
  code_start += gfx_data->mem_start;
1012
1013
  gfx_data->code_seg = code_start >> 4;
1014
1015
  // printf("code start = 0x%x, code_seg = 0x%x\n", code_start, gfx_data->code_seg);
1016
1017
  for(i = 0; i < sizeof gfx_data->jmp_table / sizeof *gfx_data->jmp_table; i++) {
1018
    gfx_data->jmp_table[i] = (gfx_data->code_seg << 16) + ((unsigned short *) code_start)[i];
1019
  }
1020
1021
#if 0
1022
  for(i = 0; i < 12; i++) {
1023
    printf("%d: 0x%x\n", i, gfx_data->jmp_table[i]);
1024
  }
1025
1026
  for(i = 0; i < gfx_data->menu_entries; i++) {
1027
    printf(">%s< - >%s<\n",
1028
      gfx_data->menu_list + i * gfx_data->menu_entry_len,
1029
      gfx_data->args_list + i * gfx_data->args_entry_len
1030
    );
1031
  }
1032
1033
  printf("def: >%s<\n", gfx_data->menu_default_entry);
1034
#endif
1035
1036
1037
  /* switch to graphics mode */
1038
1039
  if(gfx_init(gfx_data)) return;
1040
1041
  gfx_setup_menu(gfx_data);
1042
1043
  i = gfx_input(gfx_data, &selected_entry);
1044
1045
  /* ESC -> show text menu */
1046
  if(i == 1) {
1047
    gfx_done(gfx_data);
1048
    grub_timeout = -1;
1049
1050
    return;
1051
  }
1052
1053
  gfx_done(gfx_data);
1054
1055
  heap = saved_heap;	/* free most of the graphics data */
1056
1057
  // printf("cmdline: >%s<, entry = %d\n", gfx_data->cmdline, selected_entry);
1058
1059
  if(selected_entry < 0 || selected_entry > num_entries) return;
1060
1061
1062
  /* create new config with modified kernel option */
1063
1064
  cfg = get_entry(config_entries, selected_entry, 1);
1065
1066
  new_config = heap;
1067
1068
  for(i = 0; ; i++) {
1069
    s = get_entry(cfg, i, 0);
1070
    if(!*s) {
1071
      if(!i) *heap++ = 0;
1072
      *heap++ = 0;
1073
      break;
1074
    }
1075
    if(!memcmp(s, "kernel", 6) && (s[6] == ' ' || s[6] == '\t')) {
1076
      t = skip_to(0, s);
1077
      if(*t) t = skip_to(0, t);
1078
      memmove(heap, s, t - s);
1079
      heap += t - s;
1080
      *heap++ = ' ';
1081
      strcpy(heap, gfx_data->cmdline);
1082
      heap += strlen(gfx_data->cmdline) + 1;
1083
    }
1084
    else {
1085
      strcpy(heap, s);
1086
      heap += strlen(s) + 1;
1087
    }
1088
  }
1089
1090
  *heap++ = 0;
1091
1092
  // hexdump(new_config, heap - new_config);
1093
  // getkey();
1094
1095
  run_script(new_config, heap);
1096
}
1097
1098
756
static int
1099
static int
757
get_line_from_config (char *cmdline, int maxlen, int read_from_file)
1100
get_line_from_config (char *cmdline, int maxlen, int read_from_file)
758
{
1101
{
Lines 1058-1066 Link Here
1058
	}
1401
	}
1059
      else
1402
      else
1060
	{
1403
	{
1061
	  /* Run menu interface.  */
1404
	  if (*graphics_file && !password && show_menu && grub_timeout)
1062
	  run_menu (menu_entries, config_entries, num_entries,
1405
	    {
1063
		    menu_entries + menu_len, default_entry);
1406
	      run_graphics_menu(menu_entries, config_entries, num_entries,menu_entries + menu_len, default_entry);
1407
	    }
1408
	    /* Run menu interface.  */
1409
            run_menu (menu_entries, config_entries, num_entries, menu_entries + menu_len, default_entry);
1064
	}
1410
	}
1065
    }
1411
    }
1066
}
1412
}

Return to bug 80693