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

Collapse All | Expand All

(-)grub-0.95.20040823.patched/docs/grub.texi (+10 lines)
Lines 2115-2120 Link Here
2115
* default::                     Set the default entry
2115
* default::                     Set the default entry
2116
* fallback::                    Set the fallback entry
2116
* fallback::                    Set the fallback entry
2117
* hiddenmenu::                  Hide the menu interface
2117
* hiddenmenu::                  Hide the menu interface
2118
* gfxmenu::                     Use graphical menu interface
2118
* timeout::                     Set the timeout
2119
* timeout::                     Set the timeout
2119
* title::                       Start a menu entry
2120
* title::                       Start a menu entry
2120
@end menu
2121
@end menu
Lines 2147-2152 Link Here
2147
@end deffn
2148
@end deffn
2148
2149
2149
2150
2151
@node gfxmenu
2152
@subsection gfxmenu
2153
2154
@deffn Command gfxmenu file
2155
Use the graphical menu interface. The graphics data are taken from
2156
@var{file} and must be created using 'mkbootmsg' from the gfxboot package.
2157
@end deffn
2158
2159
2150
@node hiddenmenu
2160
@node hiddenmenu
2151
@subsection hiddenmenu
2161
@subsection hiddenmenu
2152
2162
(-)grub-0.95.20040823.patched/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.95.20040823.patched/stage2/asm.S (+295 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
	leal	gfx_ofs_sys_cfg(%di),%esi
1654
	movl	gfx_ofs_mem_file(%di),%eax
1655
	movl	gfx_ofs_mem_cur(%di),%ebx
1656
	movl	gfx_ofs_mem_max(%di),%ecx
1657
	movw	%ds,%dx
1658
1659
	/* basically just a lcall, but we need %edi */
1660
	pushw	%cs
1661
	pushw	$gfx_init_50
1662
	pushl	gfx_ofs_jmp_table + 4 * 0 (%di)
1663
1664
	movl	gfx_ofs_mem_align(%di),%edi
1665
1666
	lret
1667
1668
gfx_init_50:
1669
	movl	$0,%ebx
1670
	adcl	$0,%ebx
1671
1672
	popw	%ds
1673
1674
	DATA32	call	EXT_C(real_to_prot)
1675
	.code32
1676
1677
	popl	%ebp
1678
1679
	movl	%ebx,%eax
1680
	negl	%ebx
1681
	incl	%ebx
1682
	movl	8(%ebp),%edx
1683
	movl	%ebx,gfx_ofs_ok(%edx)
1684
1685
	popl	%ebx
1686
	popl	%esi
1687
	popl	%edi
1688
1689
	popl	%ebp
1690
	ret
1691
1692
1693
/*
1694
 * int gfx_done (gfx_data_t *gfx_data)
1695
 *
1696
 * shut down gfx things
1697
 *
1698
 * return vales:
1699
 *   always 0
1700
 *   sets gfx_data->ok
1701
 */
1702
1703
ENTRY(gfx_done)
1704
	pushl	%ebp
1705
	movl	%esp, %ebp
1706
	
1707
	pushl	%edi
1708
	pushl	%esi
1709
	pushl	%ebx
1710
1711
	movl	8(%ebp),%edx
1712
	movl	%edx,%ebx
1713
	andl	$0xf,%ebx
1714
	shrl	$4,%edx
1715
1716
	pushl	%ebp
1717
1718
	call	EXT_C(prot_to_real)
1719
	.code16
1720
1721
	pushw	%ds
1722
1723
	movw	%dx,%ds
1724
1725
	lcall	*gfx_ofs_jmp_table + 4 * 1 (%bx)
1726
1727
	popw	%ds
1728
1729
	DATA32	call	EXT_C(real_to_prot)
1730
	.code32
1731
1732
	popl	%ebp
1733
1734
	xorl	%eax,%eax
1735
	movl	8(%ebp),%edx
1736
	movl	%eax,gfx_ofs_ok(%edx)
1737
1738
	popl	%ebx
1739
	popl	%esi
1740
	popl	%edi
1741
1742
	popl	%ebp
1743
	ret
1744
1745
1746
/*
1747
 * int gfx_input (gfx_data_t *gfx_data, int *menu_entry)
1748
 *
1749
 * let user enter a command line
1750
 *
1751
 * uses gfx_data->cmdline as buffer
1752
 *
1753
 * return values:
1754
 *   1: abort
1755
 *   2: boot
1756
 *   menu_entry: selected entry
1757
 */
1758
1759
ENTRY(gfx_input)
1760
	pushl	%ebp
1761
	movl	%esp, %ebp
1762
	
1763
	pushl	%edi
1764
	pushl	%esi
1765
	pushl	%ebx
1766
1767
	movl	8(%ebp),%edx
1768
	movl	%edx,%ebx
1769
	andl	$0xf,%ebx
1770
	shrl	$4,%edx
1771
1772
	pushl	%ebp
1773
1774
	call	EXT_C(prot_to_real)
1775
	.code16
1776
1777
	pushw	%ds
1778
1779
	movw	%dx,%ds
1780
	shll	$4,%edx
1781
	movl	gfx_ofs_cmdline(%bx),%edi
1782
	subl	%edx,%edi
1783
	movw	gfx_ofs_cmdline_len(%bx),%cx
1784
	movw	gfx_ofs_timeout(%bx),%ax
1785
	imulw	$18,%ax
1786
1787
	pushl	%ebp
1788
	lcall	*gfx_ofs_jmp_table + 4 * 2 (%bx)
1789
	popl	%ebp
1790
	movl	%eax,%ecx
1791
1792
	popw	%ds
1793
1794
	DATA32	call	EXT_C(real_to_prot)
1795
	.code32
1796
1797
	popl	%ebp
1798
1799
	movl	12(%ebp),%edx
1800
	movl	%ebx,(%edx)
1801
1802
	movl	%ecx,%eax
1803
1804
	popl	%ebx
1805
	popl	%esi
1806
	popl	%edi
1807
1808
	popl	%ebp
1809
	ret
1810
1811
1812
/*
1813
 * int gfx_setup_menu (gfx_data_t *gfx_data)
1814
 *
1815
 * draw boot menu
1816
 *
1817
 * return values:
1818
 *   always 0
1819
 */
1820
1821
/* menu entry descriptor */
1822
#define menu_entries		0
1823
#define menu_default		2	/* seg:ofs */
1824
#define menu_ent_list		6	/* seg:ofs */
1825
#define menu_ent_size		10
1826
#define menu_arg_list		12	/* seg:ofs */
1827
#define menu_arg_size		16
1828
#define sizeof_menu_desc	18
1829
1830
ENTRY(gfx_setup_menu)
1831
	pushl	%ebp
1832
	movl	%esp, %ebp
1833
	
1834
	pushl	%edi
1835
	pushl	%esi
1836
	pushl	%ebx
1837
1838
	movl	8(%ebp),%edx
1839
	movl	%edx,%ebx
1840
	andl	$0xf,%ebx
1841
	shrl	$4,%edx
1842
1843
	call	EXT_C(prot_to_real)
1844
	.code16
1845
1846
	pushw	%ds
1847
1848
	movw	%dx,%ds
1849
	shll	$4,%edx
1850
1851
	subw	$sizeof_menu_desc,%sp
1852
	movw	%sp,%bp
1853
1854
	movl	gfx_ofs_menu_entries(%bx),%eax
1855
	movw	%ax,menu_entries(%bp)
1856
1857
	movl	gfx_ofs_menu_default_entry(%bx),%eax
1858
	subl	%edx,%eax
1859
	movw	%ax,menu_default(%bp)
1860
	movw	%ds,menu_default+2(%bp)
1861
1862
	movl	gfx_ofs_menu_list(%bx),%eax
1863
	subl	%edx,%eax
1864
	movw	%ax,menu_ent_list(%bp)
1865
	movw	%ds,menu_ent_list+2(%bp)
1866
1867
	movl	gfx_ofs_menu_entry_len(%bx),%eax
1868
	movw	%ax,menu_ent_size(%bp)
1869
1870
	movl	gfx_ofs_args_list(%bx),%eax
1871
	subl	%edx,%eax
1872
	movw	%ax,menu_arg_list(%bp)
1873
	movw	%ds,menu_arg_list+2(%bp)
1874
1875
	movl	gfx_ofs_args_entry_len(%bx),%eax
1876
	movw	%ax,menu_arg_size(%bp)
1877
1878
	movw	%bp,%si
1879
	pushw	%ss
1880
	popw	%es
1881
	
1882
	lcall	%ds: *gfx_ofs_jmp_table + 4 * 3 (%bx)
1883
1884
	addw	$sizeof_menu_desc,%sp
1885
1886
	popw	%ds
1887
1888
	DATA32	call	EXT_C(real_to_prot)
1889
	.code32
1890
1891
	xorl	%eax,%eax
1892
1893
	popl	%ebx
1894
	popl	%esi
1895
	popl	%edi
1896
1897
	popl	%ebp
1898
	ret
1899
1900
1901
/*
1902
 *
1903
 * end graphics stuff
1904
 *
1905
 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1906
 */
1907
1613
		
1908
		
1614
/*
1909
/*
1615
 * gateA20(int linear)
1910
 * gateA20(int linear)
(-)grub-0.95.20040823.patched/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 4825-4830 Link Here
4825
  &builtin_find,
4847
  &builtin_find,
4826
  &builtin_fstest,
4848
  &builtin_fstest,
4827
  &builtin_geometry,
4849
  &builtin_geometry,
4850
  &builtin_gfxmenu,
4828
  &builtin_halt,
4851
  &builtin_halt,
4829
  &builtin_help,
4852
  &builtin_help,
4830
  &builtin_hiddenmenu,
4853
  &builtin_hiddenmenu,
(-)grub-0.95.20040823.patched/stage2/shared.h (+56 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
#define gfx_ofs_mem_file		0x70
395
#define gfx_ofs_mem_align		0x74
396
397
377
#ifndef ASM_FILE
398
#ifndef ASM_FILE
378
/*
399
/*
379
 *  Below this should be ONLY defines and other constructs for C code.
400
 *  Below this should be ONLY defines and other constructs for C code.
Lines 595-600 Link Here
595
extern int default_entry;
616
extern int default_entry;
596
extern int current_entryno;
617
extern int current_entryno;
597
618
619
620
/*
621
 * graphics menu stuff
622
 *
623
 * Note: gfx_data and all data referred to in it must lie within a 64k area.
624
 */
625
typedef struct {
626
  unsigned ok;			/* set while we're in graphics mode */
627
  unsigned mem_start, mem_cur, mem_max;
628
  unsigned code_seg;		/* code segment of binary graphics code */
629
  unsigned jmp_table[12];	/* link to graphics functions */
630
  unsigned char sys_cfg[8];	/* sys_cfg[0]: identifies boot loader (grub == 2) */
631
  char *cmdline;		/* command line returned by gfx_input() */
632
  unsigned cmdline_len;		/* length of the above */
633
  char *menu_list;		/* list of menu entries, each of fixed length (menu_entry_len) */
634
  char *menu_default_entry;	/* the default entry */
635
  unsigned menu_entries;	/* number of entries in menu_list */
636
  unsigned menu_entry_len;	/* one entry */
637
  char *args_list;		/* same structure as menu_list, menu_entries entries */
638
  unsigned args_entry_len;	/* one entry */
639
  unsigned timeout;		/* in seconds (0: no timeout) */
640
  unsigned mem_file;		/* aligned gfx file start */
641
  unsigned mem_align;		/* aligned cpio file start */
642
} __attribute__ ((packed)) gfx_data_t;
643
644
extern gfx_data_t *graphics_data;
645
646
/* pointer to graphics image data */
647
extern char graphics_file[64];
648
649
int gfx_init(gfx_data_t *gfx_data);
650
int gfx_done(gfx_data_t *gfx_data);
651
int gfx_input(gfx_data_t *gfx_data, int *menu_entry);
652
int gfx_setup_menu(gfx_data_t *gfx_data);
653
598
/* The constants for password types.  */
654
/* The constants for password types.  */
599
typedef enum
655
typedef enum
600
{
656
{
(-)grub-0.95.20040823.patched/stage2/stage2.c (-3 / +421 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
#if 0
766
/* for debugging */
767
static void hexdump(unsigned char *buf, unsigned len)
768
{
769
  int i, j = 0;
770
  char s[17];
771
  unsigned addr = (unsigned) buf;
772
773
  s[16] = 0;
774
  while(len--) {
775
    i = buf[j];
776
    i = i & 0xff;
777
    s[j & 15] = (i >= 0x20 && i <= 0x7e) ? i : '.';
778
    if(!(j & 15)) {
779
      printf("%x  ", j + addr);
780
    }
781
    if(!(j & 7) && (j & 15)) printf(" ");
782
    /* stupid grub_printf */
783
    printf("%x", (i >> 4) & 0x0f);
784
    printf("%x ", i & 0x0f);
785
    if(!(++j & 15)) {
786
      printf(" %s\n", s);
787
    }
788
  }
789
790
  if(j & 15) {
791
    s[j & 15] = 0;
792
    if(!(j & 8)) printf(" ");
793
    i = 1 + 3 * (16 - (j & 15));
794
    while(i--) printf(" ");
795
    printf("%s\n", s);
796
  }
797
}
798
#endif
799
800
/*
801
 * Go through config entry and find kernel args, if any.
802
 */
803
static char *get_kernel_args(char *cfg)
804
{
805
  int j;
806
  char *s, *t = "";
807
808
  for(j = 0; ; j++) {
809
    s = get_entry(cfg, j, 0);
810
    if(!*s) break;
811
    if(!memcmp(s, "kernel", 6) && (s[6] == ' ' || s[6] == '\t')) {
812
      t = skip_to(0, s);
813
      if(*t) t = skip_to(0, t);
814
      break;
815
    }
816
  }
817
818
  return t;
819
}
820
821
822
/*
823
 * Check header and return code start offset.
824
 */
825
static unsigned magic_ok(unsigned char *buf)
826
{
827
  if(
828
    *(unsigned *) buf == 0x0b2d97f00 &&		/* magic id */
829
    buf[4] == 5					/* version 5 */
830
  ) {
831
    return *(unsigned *) (buf + 8);
832
  }
833
834
  return 0;
835
}
836
837
838
/*
839
 * Search cpio archive for gfx file.
840
 */
841
static unsigned find_file(unsigned char *buf, unsigned len, unsigned *gfx_file_start)
842
{
843
  unsigned i, fname_len, flen, code_start = 0;
844
845
  *gfx_file_start = 0;
846
847
  for(i = 0; i < len;) {
848
    if((len - i) >= 0x1a && (buf[i] + (buf[i + 1] << 8)) == 0x71c7) {
849
      fname_len = *(unsigned short *) (buf + i + 20);
850
      flen = *(unsigned short *) (buf + i + 24) + (*(unsigned short *) (buf + i + 22) << 16);
851
      i += 26 + fname_len;
852
      i = ((i + 1) & ~1);
853
      if((code_start = magic_ok(buf + i))) {
854
        *gfx_file_start = i;
855
        return code_start;
856
      }
857
      i += flen;
858
      i = ((i + 1) & ~1);
859
    }
860
    else {
861
      break;
862
    }
863
  }
864
865
  return code_start;
866
}
867
868
869
/*
870
 * Leave that much space on the heap. Everything else goes to the graphics
871
 * functions.
872
 *
873
 * 0x2000 is _not_ enough
874
 */
875
#define MIN_HEAP_SIZE	0x4000
876
877
/* gfx code needs at least this much free memory */
878
#define MIN_GFX_FREE	0xc000
879
880
/*
881
 * Does normally not return.
882
 */
883
static void
884
run_graphics_menu (char *menu_entries, char *config_entries, int num_entries,
885
	  char *heap, int entryno)
886
{
887
  unsigned char *buf;
888
  unsigned u, buf_size, code_start, file_start;
889
  char *s, *t, *cfg, *new_config;
890
  char *saved_heap;
891
  int i, j, max_len;
892
  int selected_entry;
893
  gfx_data_t *gfx_data;
894
895
  /*
896
   * check gfx_data_t struct offsets for consistency; gcc will optimize away
897
   * the whole block
898
   */
899
900
  /* dummy function to make ld fail */
901
  {
902
    extern void wrong_struct_size(void);
903
    #define gfx_ofs_check(a) if(gfx_ofs_##a != (char *) &gfx_data->a - (char *) gfx_data) wrong_struct_size();
904
    gfx_ofs_check(ok);
905
    gfx_ofs_check(mem_start);
906
    gfx_ofs_check(mem_cur);
907
    gfx_ofs_check(mem_max);
908
    gfx_ofs_check(code_seg);
909
    gfx_ofs_check(jmp_table);
910
    gfx_ofs_check(sys_cfg);
911
    gfx_ofs_check(cmdline);
912
    gfx_ofs_check(cmdline_len);
913
    gfx_ofs_check(menu_list);
914
    gfx_ofs_check(menu_default_entry);
915
    gfx_ofs_check(menu_entries);
916
    gfx_ofs_check(menu_entry_len);
917
    gfx_ofs_check(args_list);
918
    gfx_ofs_check(args_entry_len);
919
    gfx_ofs_check(timeout);
920
    gfx_ofs_check(mem_file);
921
    gfx_ofs_check(mem_align);
922
    #undef gfx_ofs_check
923
  }
924
925
  if(!num_entries) return;
926
927
  graphics_data = gfx_data = (gfx_data_t *) heap;
928
  heap += sizeof *gfx_data;
929
  memset(gfx_data, 0, sizeof *gfx_data);
930
931
  gfx_data->sys_cfg[0] = 2;	/* bootloader: grub */
932
  gfx_data->timeout = grub_timeout >= 0 ? grub_timeout : 0;
933
934
935
  /* setup command line edit buffer */
936
937
  gfx_data->cmdline_len = 256;
938
939
  gfx_data->cmdline = heap;
940
  heap += gfx_data->cmdline_len;
941
  memset(gfx_data->cmdline, 0, gfx_data->cmdline_len);
942
943
944
  /* setup menu entries */
945
946
  for(i = max_len = 0; i < num_entries; i++) {
947
    j = strlen(get_entry(menu_entries, i, 0));
948
    if(j > max_len) max_len = j;
949
  }
950
951
  if(!max_len) return;
952
953
  gfx_data->menu_entry_len = max_len + 1;
954
  gfx_data->menu_entries = num_entries;
955
956
  gfx_data->menu_list = heap;
957
  heap += gfx_data->menu_entry_len * gfx_data->menu_entries;
958
959
  memset(gfx_data->menu_list, 0, gfx_data->menu_entry_len * gfx_data->menu_entries);
960
961
  for(i = 0; i < (int) gfx_data->menu_entries; i++) {
962
    strcpy(gfx_data->menu_list + i * gfx_data->menu_entry_len, get_entry(menu_entries, i, 0));
963
  }
964
965
  gfx_data->menu_default_entry = gfx_data->menu_list + entryno * gfx_data->menu_entry_len;
966
967
968
  /* setup list of kernel args */
969
970
  for(i = max_len = 0; i < num_entries; i++) {
971
    s = get_kernel_args(get_entry(config_entries, i, 1));
972
    j = strlen(s);
973
    if(j > max_len) max_len = j;
974
  }
975
976
  gfx_data->args_entry_len = max_len + 1;
977
978
  gfx_data->args_list = heap;
979
  heap += gfx_data->args_entry_len * gfx_data->menu_entries;
980
981
  memset(gfx_data->args_list, 0, gfx_data->args_entry_len * gfx_data->menu_entries);
982
983
  for(i = 0; i < (int) gfx_data->menu_entries; i++) {
984
    strcpy(gfx_data->args_list + i* gfx_data->args_entry_len, get_kernel_args(get_entry(config_entries, i, 1)));
985
  }
986
987
988
  /* go back here when we no longer need the graphics data */
989
  saved_heap = heap;
990
991
992
  /* get memory area to be used by graphics functions */
993
994
  buf = (unsigned char *) (((unsigned) heap + 0xf) & ~0xf);
995
996
  buf_size = (unsigned char *) &buf - buf - MIN_HEAP_SIZE;
997
  buf_size &= ~0xf;
998
999
  /* too small */
1000
  if(buf_size < 0x10000) return;
1001
1002
  gfx_data->mem_start = (unsigned) buf;
1003
  gfx_data->mem_max = gfx_data->mem_start + buf_size;
1004
1005
#if 0
1006
  printf("graphics menu\n");
1007
  printf(
1008
    "heap = 0x%x, buf = 0x%x (0x%x bytes), graphics_file = %s\n",
1009
    heap, gfx_data->mem_start, buf_size, graphics_file
1010
  );
1011
  getkey();
1012
#endif
1013
1014
  heap += buf_size;
1015
1016
1017
  /* read the file */
1018
1019
  if(!grub_open(graphics_file)) {
1020
    printf("graphics file \"%s\" missing, press a key to continue...\n", graphics_file);
1021
    getkey();
1022
    return;
1023
  }
1024
1025
  i = grub_read(buf, buf_size);
1026
1027
  grub_close();
1028
1029
  if(i <= 0) {
1030
    printf("error reading \"%s\", press a key to continue...\n", graphics_file);
1031
    getkey();
1032
    return;
1033
  }
1034
1035
  /* besides the file, we need some working memory, too */
1036
  if(i + MIN_GFX_FREE + 0x0f >= (int) buf_size) {
1037
    printf("file \"%s\" too large, press a key to continue...\n", graphics_file);
1038
    getkey();
1039
    return;
1040
  }
1041
1042
  gfx_data->mem_cur = gfx_data->mem_start + ((i + 0x0f + 3) & ~3);	/* align it */
1043
1044
#if 0
1045
  printf("image: %d bytes (%d bytes left)\n", i, gfx_data->mem_max - gfx_data->mem_cur);
1046
  getkey();
1047
#endif
1048
1049
1050
  /* locate file inside cpio archive */
1051
  if(!(code_start = find_file(buf, i, &file_start))) {
1052
    printf("\"%s\" has wrong format, press a key to continue...\n", graphics_file);
1053
    getkey();
1054
    return;
1055
  }
1056
1057
1058
  /* align it */
1059
  u = (-(code_start + gfx_data->mem_start + file_start)) & 0x0f;
1060
  gfx_data->mem_align = gfx_data->mem_start + u;
1061
  gfx_data->mem_file = gfx_data->mem_align + file_start;
1062
  if(u) {
1063
    memcpy((void *) gfx_data->mem_align, (void *) gfx_data->mem_start, i);
1064
  }
1065
1066
  /* init interface to graphics functions */
1067
1068
  code_start += gfx_data->mem_file;
1069
1070
#if 0
1071
  printf("code_start: 0x%x, file_start: 0x%x, mem_align = 0x%x, mem_file = 0x%x\n",
1072
    code_start, file_start, gfx_data->mem_align, gfx_data->mem_file
1073
  );
1074
  getkey();
1075
#endif
1076
1077
  gfx_data->code_seg = code_start >> 4;
1078
1079
#if 0
1080
  printf("code start = 0x%x, code_seg = 0x%x\n", code_start, gfx_data->code_seg);
1081
#endif
1082
1083
  for(i = 0; (unsigned) i < sizeof gfx_data->jmp_table / sizeof *gfx_data->jmp_table; i++) {
1084
    gfx_data->jmp_table[i] = (gfx_data->code_seg << 16) + ((unsigned short *) code_start)[i];
1085
  }
1086
1087
#if 0
1088
  for(i = 0; i < 12; i++) {
1089
    printf("%d: 0x%x\n", i, gfx_data->jmp_table[i]);
1090
  }
1091
1092
  for(i = 0; i < gfx_data->menu_entries; i++) {
1093
    printf(">%s< - >%s<\n",
1094
      gfx_data->menu_list + i * gfx_data->menu_entry_len,
1095
      gfx_data->args_list + i * gfx_data->args_entry_len
1096
    );
1097
  }
1098
1099
  printf("def: >%s<\n", gfx_data->menu_default_entry);
1100
#endif
1101
1102
1103
  /* switch to graphics mode */
1104
1105
  if(gfx_init(gfx_data)) {
1106
#if 0
1107
    printf("gfx_init failed\n");
1108
    getkey();
1109
#endif
1110
    return;
1111
  }
1112
1113
  gfx_setup_menu(gfx_data);
1114
1115
  i = gfx_input(gfx_data, &selected_entry);
1116
1117
  /* ESC -> show text menu */
1118
  if(i == 1) {
1119
    gfx_done(gfx_data);
1120
    grub_timeout = -1;
1121
1122
    return;
1123
  }
1124
1125
  gfx_done(gfx_data);
1126
1127
  heap = saved_heap;	/* free most of the graphics data */
1128
1129
  // printf("cmdline: >%s<, entry = %d\n", gfx_data->cmdline, selected_entry);
1130
1131
  if(selected_entry < 0 || selected_entry > num_entries) return;
1132
1133
1134
  /* create new config with modified kernel option */
1135
1136
  cfg = get_entry(config_entries, selected_entry, 1);
1137
1138
  new_config = heap;
1139
1140
  for(i = 0; ; i++) {
1141
    s = get_entry(cfg, i, 0);
1142
    if(!*s) {
1143
      if(!i) *heap++ = 0;
1144
      *heap++ = 0;
1145
      break;
1146
    }
1147
    if(!memcmp(s, "kernel", 6) && (s[6] == ' ' || s[6] == '\t')) {
1148
      t = skip_to(0, s);
1149
      if(*t) t = skip_to(0, t);
1150
      memmove(heap, s, t - s);
1151
      heap += t - s;
1152
      *heap++ = ' ';
1153
      strcpy(heap, gfx_data->cmdline);
1154
      heap += strlen(gfx_data->cmdline) + 1;
1155
    }
1156
    else {
1157
      strcpy(heap, s);
1158
      heap += strlen(s) + 1;
1159
    }
1160
  }
1161
1162
  *heap++ = 0;
1163
1164
  // hexdump(new_config, heap - new_config);
1165
  // getkey();
1166
1167
  run_script(new_config, heap);
1168
}
1169
1170
756
static int
1171
static int
757
get_line_from_config (char *cmdline, int maxlen, int read_from_file)
1172
get_line_from_config (char *cmdline, int maxlen, int read_from_file)
758
{
1173
{
Lines 1058-1066 Link Here
1058
	}
1473
	}
1059
      else
1474
      else
1060
	{
1475
	{
1061
	  /* Run menu interface.  */
1476
	  if (*graphics_file && !password && show_menu && grub_timeout)
1062
	  run_menu (menu_entries, config_entries, num_entries,
1477
	    {
1063
		    menu_entries + menu_len, default_entry);
1478
	      run_graphics_menu(menu_entries, config_entries, num_entries,menu_entries + menu_len, default_entry);
1479
	    }
1480
	    /* Run menu interface.  */
1481
            run_menu (menu_entries, config_entries, num_entries, menu_entries + menu_len, default_entry);
1064
	}
1482
	}
1065
    }
1483
    }
1066
}
1484
}

Return to bug 79219