~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to debian/grub-extras/lua/lundump.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:
 
1
/*
 
2
** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $
 
3
** load precompiled Lua chunks
 
4
** See Copyright Notice in lua.h
 
5
*/
 
6
 
 
7
#if 0
 
8
#include <string.h>
 
9
#endif
 
10
 
 
11
#define lundump_c
 
12
#define LUA_CORE
 
13
 
 
14
#include "lua.h"
 
15
 
 
16
#include "ldebug.h"
 
17
#include "ldo.h"
 
18
#include "lfunc.h"
 
19
#include "lmem.h"
 
20
#include "lobject.h"
 
21
#include "lstring.h"
 
22
#include "lundump.h"
 
23
#include "lzio.h"
 
24
 
 
25
typedef struct {
 
26
 lua_State* L;
 
27
 ZIO* Z;
 
28
 Mbuffer* b;
 
29
 const char* name;
 
30
} LoadState;
 
31
 
 
32
#ifdef LUAC_TRUST_BINARIES
 
33
#define IF(c,s)
 
34
#define error(S,s)
 
35
#else
 
36
#define IF(c,s)         if (c) error(S,s)
 
37
 
 
38
static void error(LoadState* S, const char* why)
 
39
{
 
40
 luaO_pushfstring(S->L,"%s: %s in precompiled chunk",S->name,why);
 
41
 luaD_throw(S->L,LUA_ERRSYNTAX);
 
42
}
 
43
#endif
 
44
 
 
45
#define LoadMem(S,b,n,size)     LoadBlock(S,b,(n)*(size))
 
46
#define LoadByte(S)             (lu_byte)LoadChar(S)
 
47
#define LoadVar(S,x)            LoadMem(S,&x,1,sizeof(x))
 
48
#define LoadVector(S,b,n,size)  LoadMem(S,b,n,size)
 
49
 
 
50
static void LoadBlock(LoadState* S, void* b, size_t size)
 
51
{
 
52
 size_t r=luaZ_read(S->Z,b,size);
 
53
 IF (r!=0, "unexpected end");
 
54
}
 
55
 
 
56
static int LoadChar(LoadState* S)
 
57
{
 
58
 char x;
 
59
 LoadVar(S,x);
 
60
 return x;
 
61
}
 
62
 
 
63
static int LoadInt(LoadState* S)
 
64
{
 
65
 int x;
 
66
 LoadVar(S,x);
 
67
 IF (x<0, "bad integer");
 
68
 return x;
 
69
}
 
70
 
 
71
static lua_Number LoadNumber(LoadState* S)
 
72
{
 
73
 lua_Number x;
 
74
 LoadVar(S,x);
 
75
 return x;
 
76
}
 
77
 
 
78
static TString* LoadString(LoadState* S)
 
79
{
 
80
 size_t size;
 
81
 LoadVar(S,size);
 
82
 if (size==0)
 
83
  return NULL;
 
84
 else
 
85
 {
 
86
  char* s=luaZ_openspace(S->L,S->b,size);
 
87
  LoadBlock(S,s,size);
 
88
  return luaS_newlstr(S->L,s,size-1);           /* remove trailing '\0' */
 
89
 }
 
90
}
 
91
 
 
92
static void LoadCode(LoadState* S, Proto* f)
 
93
{
 
94
 int n=LoadInt(S);
 
95
 f->code=luaM_newvector(S->L,n,Instruction);
 
96
 f->sizecode=n;
 
97
 LoadVector(S,f->code,n,sizeof(Instruction));
 
98
}
 
99
 
 
100
static Proto* LoadFunction(LoadState* S, TString* p);
 
101
 
 
102
static void LoadConstants(LoadState* S, Proto* f)
 
103
{
 
104
 int i,n;
 
105
 n=LoadInt(S);
 
106
 f->k=luaM_newvector(S->L,n,TValue);
 
107
 f->sizek=n;
 
108
 for (i=0; i<n; i++) setnilvalue(&f->k[i]);
 
109
 for (i=0; i<n; i++)
 
110
 {
 
111
  TValue* o=&f->k[i];
 
112
  int t=LoadChar(S);
 
113
  switch (t)
 
114
  {
 
115
   case LUA_TNIL:
 
116
        setnilvalue(o);
 
117
        break;
 
118
   case LUA_TBOOLEAN:
 
119
        setbvalue(o,LoadChar(S)!=0);
 
120
        break;
 
121
   case LUA_TNUMBER:
 
122
        setnvalue(o,LoadNumber(S));
 
123
        break;
 
124
   case LUA_TSTRING:
 
125
        setsvalue2n(S->L,o,LoadString(S));
 
126
        break;
 
127
   default:
 
128
        error(S,"bad constant");
 
129
        break;
 
130
  }
 
131
 }
 
132
 n=LoadInt(S);
 
133
 f->p=luaM_newvector(S->L,n,Proto*);
 
134
 f->sizep=n;
 
135
 for (i=0; i<n; i++) f->p[i]=NULL;
 
136
 for (i=0; i<n; i++) f->p[i]=LoadFunction(S,f->source);
 
137
}
 
138
 
 
139
static void LoadDebug(LoadState* S, Proto* f)
 
140
{
 
141
 int i,n;
 
142
 n=LoadInt(S);
 
143
 f->lineinfo=luaM_newvector(S->L,n,int);
 
144
 f->sizelineinfo=n;
 
145
 LoadVector(S,f->lineinfo,n,sizeof(int));
 
146
 n=LoadInt(S);
 
147
 f->locvars=luaM_newvector(S->L,n,LocVar);
 
148
 f->sizelocvars=n;
 
149
 for (i=0; i<n; i++) f->locvars[i].varname=NULL;
 
150
 for (i=0; i<n; i++)
 
151
 {
 
152
  f->locvars[i].varname=LoadString(S);
 
153
  f->locvars[i].startpc=LoadInt(S);
 
154
  f->locvars[i].endpc=LoadInt(S);
 
155
 }
 
156
 n=LoadInt(S);
 
157
 f->upvalues=luaM_newvector(S->L,n,TString*);
 
158
 f->sizeupvalues=n;
 
159
 for (i=0; i<n; i++) f->upvalues[i]=NULL;
 
160
 for (i=0; i<n; i++) f->upvalues[i]=LoadString(S);
 
161
}
 
162
 
 
163
static Proto* LoadFunction(LoadState* S, TString* p)
 
164
{
 
165
 Proto* f;
 
166
 if (++S->L->nCcalls > LUAI_MAXCCALLS) error(S,"code too deep");
 
167
 f=luaF_newproto(S->L);
 
168
 setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
 
169
 f->source=LoadString(S); if (f->source==NULL) f->source=p;
 
170
 f->linedefined=LoadInt(S);
 
171
 f->lastlinedefined=LoadInt(S);
 
172
 f->nups=LoadByte(S);
 
173
 f->numparams=LoadByte(S);
 
174
 f->is_vararg=LoadByte(S);
 
175
 f->maxstacksize=LoadByte(S);
 
176
 LoadCode(S,f);
 
177
 LoadConstants(S,f);
 
178
 LoadDebug(S,f);
 
179
 IF (!luaG_checkcode(f), "bad code");
 
180
 S->L->top--;
 
181
 S->L->nCcalls--;
 
182
 return f;
 
183
}
 
184
 
 
185
static void LoadHeader(LoadState* S)
 
186
{
 
187
 char h[LUAC_HEADERSIZE];
 
188
 char s[LUAC_HEADERSIZE];
 
189
 luaU_header(h);
 
190
 LoadBlock(S,s,LUAC_HEADERSIZE);
 
191
 IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
 
192
}
 
193
 
 
194
/*
 
195
** load precompiled chunk
 
196
*/
 
197
Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
 
198
{
 
199
 LoadState S;
 
200
 if (*name=='@' || *name=='=')
 
201
  S.name=name+1;
 
202
 else if (*name==LUA_SIGNATURE[0])
 
203
  S.name="binary string";
 
204
 else
 
205
  S.name=name;
 
206
 S.L=L;
 
207
 S.Z=Z;
 
208
 S.b=buff;
 
209
 LoadHeader(&S);
 
210
 return LoadFunction(&S,luaS_newliteral(L,"=?"));
 
211
}
 
212
 
 
213
/*
 
214
* make header
 
215
*/
 
216
void luaU_header (char* h)
 
217
{
 
218
 int x=1;
 
219
 memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
 
220
 h+=sizeof(LUA_SIGNATURE)-1;
 
221
 *h++=(char)LUAC_VERSION;
 
222
 *h++=(char)LUAC_FORMAT;
 
223
 *h++=(char)*(char*)&x;                         /* endianness */
 
224
 *h++=(char)sizeof(int);
 
225
 *h++=(char)sizeof(size_t);
 
226
 *h++=(char)sizeof(Instruction);
 
227
 *h++=(char)sizeof(lua_Number);
 
228
 *h++=(char)(((lua_Number)0.5)==0);             /* is lua_Number integral? */
 
229
}