Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
93996cf7
Commit
93996cf7
authored
May 13, 2021
by
longpanda
Browse files
1. Optimization for WIMBOOT mode.
2. Add WIMBOOT for UEFI mode.
parent
ca62128f
Changes
120
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
2796 additions
and
0 deletions
+2796
-0
wimboot/wimboot-2.7.3/src/Makefile
wimboot/wimboot-2.7.3/src/Makefile
+187
-0
wimboot/wimboot-2.7.3/src/assert.h
wimboot/wimboot-2.7.3/src/assert.h
+39
-0
wimboot/wimboot-2.7.3/src/bootapp.h
wimboot/wimboot-2.7.3/src/bootapp.h
+318
-0
wimboot/wimboot-2.7.3/src/byteswap.h
wimboot/wimboot-2.7.3/src/byteswap.h
+183
-0
wimboot/wimboot-2.7.3/src/cmdline.c
wimboot/wimboot-2.7.3/src/cmdline.c
+151
-0
wimboot/wimboot-2.7.3/src/cmdline.h
wimboot/wimboot-2.7.3/src/cmdline.h
+48
-0
wimboot/wimboot-2.7.3/src/compiler.h
wimboot/wimboot-2.7.3/src/compiler.h
+43
-0
wimboot/wimboot-2.7.3/src/cookie.c
wimboot/wimboot-2.7.3/src/cookie.c
+92
-0
wimboot/wimboot-2.7.3/src/coverity-model.c
wimboot/wimboot-2.7.3/src/coverity-model.c
+15
-0
wimboot/wimboot-2.7.3/src/cpio.c
wimboot/wimboot-2.7.3/src/cpio.c
+134
-0
wimboot/wimboot-2.7.3/src/cpio.h
wimboot/wimboot-2.7.3/src/cpio.h
+78
-0
wimboot/wimboot-2.7.3/src/ctype.h
wimboot/wimboot-2.7.3/src/ctype.h
+47
-0
wimboot/wimboot-2.7.3/src/die.c
wimboot/wimboot-2.7.3/src/die.c
+72
-0
wimboot/wimboot-2.7.3/src/efi.c
wimboot/wimboot-2.7.3/src/efi.c
+34
-0
wimboot/wimboot-2.7.3/src/efi.h
wimboot/wimboot-2.7.3/src/efi.h
+52
-0
wimboot/wimboot-2.7.3/src/efi/Base.h
wimboot/wimboot-2.7.3/src/efi/Base.h
+1021
-0
wimboot/wimboot-2.7.3/src/efi/Guid/FileInfo.h
wimboot/wimboot-2.7.3/src/efi/Guid/FileInfo.h
+71
-0
wimboot/wimboot-2.7.3/src/efi/Guid/HiiFormMapMethodGuid.h
wimboot/wimboot-2.7.3/src/efi/Guid/HiiFormMapMethodGuid.h
+25
-0
wimboot/wimboot-2.7.3/src/efi/Guid/PcAnsi.h
wimboot/wimboot-2.7.3/src/efi/Guid/PcAnsi.h
+58
-0
wimboot/wimboot-2.7.3/src/efi/Guid/WinCertificate.h
wimboot/wimboot-2.7.3/src/efi/Guid/WinCertificate.h
+128
-0
No files found.
wimboot/wimboot-2.7.3/src/Makefile
0 → 100644
View file @
93996cf7
VERSION
:=
v2.7.3
OBJECTS
:=
prefix.o startup.o callback.o main.o vsprintf.o string.o peloader.o
OBJECTS
+=
int13.o vdisk.o cpio.o stdio.o lznt1.o xca.o die.o efi.o efimain.o
OBJECTS
+=
efiguid.o efifile.o efipath.o efiboot.o efiblock.o cmdline.o
OBJECTS
+=
wimpatch.o huffman.o lzx.o wim.o wimfile.o pause.o sha1.o cookie.o
OBJECTS
+=
paging.o memmap.o
OBJECTS_i386
:=
$(
patsubst
%.o,%.i386.o,
$(OBJECTS)
)
OBJECTS_x86_64
:=
$(
patsubst
%.o,%.x86_64.o,
$(OBJECTS)
)
OBJECTS_i386_x86_64
:=
$(
patsubst
%.o,%.i386.x86_64.o,
$(OBJECTS)
)
HEADERS
:=
$(
wildcard
*
.h
)
HOST_CC
:=
$(CC)
AS
:=
$(AS)
ECHO
:=
echo
OBJCOPY
:=
objcopy
AR
:=
ar
RANLIB
:=
ranlib
CP
:=
cp
RM
:=
rm
GCAB
:=
gcab
PESIGN
:=
pesign
DIFF
:=
diff
CUT
:=
cut
BINUTILS_DIR
:=
/usr
BFD_DIR
:=
$(BINUTILS_DIR)
ZLIB_DIR
:=
/usr
HOST_CFLAGS
+=
-Wall
-W
-Werror
CFLAGS
+=
-Os
-ffreestanding
-Wall
-W
-Werror
-nostdinc
-I
.
-fshort-wchar
CFLAGS
+=
-DVERSION
=
"
\"
$(VERSION)
\"
"
CFLAGS_i386
+=
-m32
-march
=
i386
-malign-double
-fno-pic
CFLAGS_x86_64
+=
-m64
-mno-red-zone
-fpie
# Enable stack protection if available
#
SPG_TEST
=
$(CC)
-fstack-protector-strong
-mstack-protector-guard
=
global
\
-x
c
-c
/dev/null
-o
/dev/null
>
/dev/null 2>&1
SPG_FLAGS
:=
$(
shell
$(SPG_TEST)
&&
$(ECHO)
'-fstack-protector-strong '
\
'-mstack-protector-guard=global'
)
CFLAGS
+=
$(SPG_FLAGS)
# Inhibit unwanted debugging information
CFI_TEST
=
$(CC)
-fno-dwarf2-cfi-asm
-fno-exceptions
-fno-unwind-tables
\
-fno-asynchronous-unwind-tables
-x
c
-c
/dev/null
\
-o
/dev/null
>
/dev/null 2>&1
CFI_FLAGS
:=
$(
shell
$(CFI_TEST)
&&
\
$(ECHO)
'-fno-dwarf2-cfi-asm -fno-exceptions '
\
'-fno-unwind-tables -fno-asynchronous-unwind-tables'
)
WORKAROUND_CFLAGS
+=
$(CFI_FLAGS)
# Add -maccumulate-outgoing-args if required by this version of gcc
MS_ABI_TEST_CODE
:=
extern void __attribute__
((
ms_abi
))
ms_abi
()
;
\
void sysv_abi
(
void
)
{
ms_abi
()
;
}
MS_ABI_TEST
=
$(ECHO)
'
$(MS_ABI_TEST_CODE)
'
|
\
$(CC)
-m64
-mno-accumulate-outgoing-args
-x
c
-c
-
-o
/dev/null
\
>
/dev/null 2>&1
MS_ABI_FLAGS
:=
$(
shell
$(MS_ABI_TEST)
||
$(ECHO)
'-maccumulate-outgoing-args'
)
WORKAROUND_CFLAGS
+=
$(MS_ABI_FLAGS)
# Inhibit warnings from taking address of packed struct members
WNAPM_TEST
=
$(CC)
-Wno-address-of-packed-member
-x
c
-c
/dev/null
\
-o
/dev/null
>
/dev/null 2>&1
WNAPM_FLAGS
:=
$(
shell
$(WNAPM_TEST)
&&
\
$(ECHO)
'-Wno-address-of-packed-member'
)
WORKAROUND_CFLAGS
+=
$(WNAPM_FLAGS)
# Inhibit LTO
LTO_TEST
=
$(CC)
-fno-lto
-x
c
-c
/dev/null
-o
/dev/null
>
/dev/null 2>&1
LTO_FLAGS
:=
$(
shell
$(LTO_TEST)
&&
$(ECHO)
'-fno-lto'
)
WORKAROUND_CFLAGS
+=
$(LTO_FLAGS)
CFLAGS
+=
$(WORKAROUND_CFLAGS)
CFLAGS
+=
$(EXTRA_CFLAGS)
ifneq
($(DEBUG),)
CFLAGS
+=
-DDEBUG
=
$(DEBUG)
endif
CFLAGS
+=
-include
compiler.h
###############################################################################
#
# Final targets
all
:
wimboot wimboot.i386 wimboot.x86_64 wimboot.cab
wimboot
:
wimboot.x86_64 Makefile
$(CP)
$<
$@
$(CP)
$@
../
$@
wimboot.%.elf
:
prefix.%.o lib.%.a script.lds Makefile
$(LD)
-m
elf_
$*
-T
script.lds
-o
$@
-q
-Map
wimboot.
$*
.map
\
prefix.
$*
.o lib.
$*
.a
wimboot.%.unsigned
:
wimboot.%.elf efireloc Makefile
$(OBJCOPY)
-Obinary
$<
$@
./efireloc
$<
$@
wimboot.%.unsigned.hash
:
wimboot.%.unsigned Makefile
$(PESIGN)
-h
-i
$<
|
$(CUT)
-d
" "
-f2-
>
$@
wimboot.%.efi
:
wimboot.%.unsigned Makefile
$(CP)
$<
$@
wimboot.%.efi.hash
:
wimboot.%.efi Makefile
$(PESIGN)
-h
-i
$<
|
$(CUT)
-d
" "
-f2-
>
$@
wimboot.%
:
wimboot.%.efi wimboot.%.efi.hash wimboot.%.unsigned.hash Makefile
$(DIFF)
wimboot.
$*
.efi.hash wimboot.
$*
.unsigned.hash
$(CP)
$<
$@
wimboot.cab
:
wimboot.i386.efi wimboot.x86_64.efi Makefile
$(GCAB)
-n
-c
$@
wimboot.i386.efi wimboot.x86_64.efi
###############################################################################
#
# i386 objects
%.i386.s
:
%.S $(HEADERS) Makefile
$(CC)
$(CFLAGS)
$(CFLAGS_i386)
-DASSEMBLY
-Ui386
-E
$<
-o
$@
%.i386.s
:
%.c $(HEADERS) Makefile
$(CC)
$(CFLAGS)
$(CFLAGS_i386)
-S
$<
-o
$@
%.i386.o
:
%.i386.s i386.i Makefile
$(AS)
--32
i386.i
$<
-o
$@
lib.i386.a
:
$(OBJECTS_i386) Makefile
$(RM)
-f
$@
$(AR)
r
$@
$(OBJECTS_i386)
$(RANLIB)
$@
###############################################################################
#
# i386 objects to be linked into an x86_64 binary
%.i386.x86_64.raw.o
:
%.i386.s i386.i Makefile
$(AS)
--64
i386.i
$<
-o
$@
%.i386.x86_64.o
:
%.i386.x86_64.raw.o Makefile
$(OBJCOPY)
--prefix-symbols
=
__i386_
$<
$@
###############################################################################
#
# x86_64 objects
%.x86_64.s
:
%.S $(HEADERS) Makefile
$(CC)
$(CFLAGS)
$(CFLAGS_x86_64)
-DASSEMBLY
-Ui386
-E
$<
-o
$@
%.x86_64.s
:
%.c $(HEADERS) Makefile
$(CC)
$(CFLAGS)
$(CFLAGS_x86_64)
-S
$<
-o
$@
%.x86_64.o
:
%.x86_64.s x86_64.i Makefile
$(AS)
--64
x86_64.i
$<
-o
$@
lib.x86_64.a
:
$(OBJECTS_x86_64) $(OBJECTS_i386_x86_64) Makefile
$(RM)
-f
$@
$(AR)
r
$@
$(OBJECTS_x86_64)
$(OBJECTS_i386_x86_64)
$(RANLIB)
$@
###############################################################################
#
# EFI relocator
EFIRELOC_CFLAGS
:=
-I
$(BINUTILS_DIR)
/include
-I
$(BFD_DIR)
/include
\
-I
$(ZLIB_DIR)
/include
-idirafter
.
EFIRELOC_LDFLAGS
:=
-L
$(BINUTILS_DIR)
/lib
-L
$(BFD_DIR)
/lib
-L
$(ZLIB_DIR)
/lib
\
-lbfd
-ldl
-liberty
-lz
-Wl
,--no-warn-search-mismatch
efireloc
:
efireloc.c Makefile
$(CC)
$(HOST_CFLAGS)
$(EFIRELOC_CFLAGS)
$<
$(EFIRELOC_LDFLAGS)
-o
$@
###############################################################################
#
# Cleanup
clean
:
$(RM)
-f
*
.s
*
.o
*
.a
*
.elf
*
.map
$(RM)
-f
efireloc
$(RM)
-f
wimboot wimboot.i386 wimboot.x86_64 ../wimboot
$(RM)
-f
wimboot.i386.unsigned wimboot.x86_64.unsigned
$(RM)
-f
wimboot.i386.efi wimboot.x86_64.efi wimboot.cab
wimboot/wimboot-2.7.3/src/assert.h
0 → 100644
View file @
93996cf7
#ifndef _ASSERT_H
#define _ASSERT_H
/*
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Assertions
*
*/
#include "wimboot.h"
#define assert(x) do { \
if ( DEBUG && ! (x) ) { \
die ( "Assertion failed at %s line %d: %s\n", \
__FILE__, __LINE__, #x ); \
} \
} while ( 0 )
#endif
/* _ASSERT_H */
wimboot/wimboot-2.7.3/src/bootapp.h
0 → 100644
View file @
93996cf7
#ifndef _BOOTAPP_H
#define _BOOTAPP_H
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Boot application data structures
*
*/
#include <stdint.h>
/** A segment:offset address */
struct
segoff
{
/** Offset */
uint16_t
offset
;
/** Segment */
uint16_t
segment
;
}
__attribute__
((
packed
));
/** A GUID */
struct
guid
{
/** 8 hex digits, big-endian */
uint32_t
a
;
/** 2 hex digits, big-endian */
uint16_t
b
;
/** 2 hex digits, big-endian */
uint16_t
c
;
/** 2 hex digits, big-endian */
uint16_t
d
;
/** 12 hex digits, big-endian */
uint8_t
e
[
6
];
}
__attribute__
((
packed
));
/** Real-mode callback parameters */
struct
bootapp_callback_params
{
/** Vector */
union
{
/** Interrupt number */
uint32_t
interrupt
;
/** Segment:offset address of real-mode function */
struct
segoff
function
;
}
vector
;
/** %eax value */
union
{
struct
{
uint8_t
al
;
uint8_t
ah
;
}
__attribute__
((
packed
));
uint16_t
ax
;
uint32_t
eax
;
};
/** %ebx value */
union
{
struct
{
uint8_t
bl
;
uint8_t
bh
;
}
__attribute__
((
packed
));
uint16_t
bx
;
uint32_t
ebx
;
};
/** %ecx value */
union
{
struct
{
uint8_t
cl
;
uint8_t
ch
;
}
__attribute__
((
packed
));
uint16_t
cx
;
uint32_t
ecx
;
};
/** %edx value */
union
{
struct
{
uint8_t
dl
;
uint8_t
dh
;
}
__attribute__
((
packed
));
uint16_t
dx
;
uint32_t
edx
;
};
/** Placeholder (for %esp?) */
uint32_t
unused_esp
;
/** Placeholder (for %ebp?) */
uint32_t
unused_ebp
;
/** %esi value */
union
{
uint16_t
si
;
uint32_t
esi
;
};
/** %edi value */
union
{
uint16_t
di
;
uint32_t
edi
;
};
/** Placeholder (for %cs?) */
uint32_t
unused_cs
;
/** %ds value */
uint32_t
ds
;
/** Placeholder (for %ss?) */
uint32_t
unused_ss
;
/** %es value */
uint32_t
es
;
/** %fs value */
uint32_t
fs
;
/** %gs value */
uint32_t
gs
;
/** eflags value */
uint32_t
eflags
;
}
__attribute__
((
packed
));
/** eflags bits */
enum
eflags
{
CF
=
(
1
<<
0
),
PF
=
(
1
<<
2
),
AF
=
(
1
<<
4
),
ZF
=
(
1
<<
6
),
SF
=
(
1
<<
7
),
OF
=
(
1
<<
11
),
};
/** Real-mode callback function table */
struct
bootapp_callback_functions
{
/**
* Call an arbitrary real-mode interrupt
*
* @v params Parameters
*/
void
(
*
call_interrupt
)
(
struct
bootapp_callback_params
*
params
);
/**
* Call an arbitrary real-mode function
*
* @v params Parameters
*/
void
(
*
call_real
)
(
struct
bootapp_callback_params
*
params
);
}
__attribute__
((
packed
));
/** Real-mode callbacks */
struct
bootapp_callback
{
/** Real-mode callback function table */
struct
bootapp_callback_functions
*
fns
;
/** Drive number for INT13 calls */
uint32_t
drive
;
}
__attribute__
((
packed
));
/** Boot application descriptor */
struct
bootapp_descriptor
{
/** Signature */
char
signature
[
8
];
/** Version */
uint32_t
version
;
/** Total length */
uint32_t
len
;
/** COFF machine type */
uint32_t
arch
;
/** Reserved */
uint32_t
reserved_0x14
;
/** Loaded PE image base address */
void
*
pe_base
;
/** Reserved */
uint32_t
reserved_0x1c
;
/** Length of loaded PE image */
uint32_t
pe_len
;
/** Offset to memory descriptor */
uint32_t
memory
;
/** Offset to boot application entry descriptor */
uint32_t
entry
;
/** Offset to ??? */
uint32_t
xxx
;
/** Offset to callback descriptor */
uint32_t
callback
;
/** Offset to pointless descriptor */
uint32_t
pointless
;
/** Reserved */
uint32_t
reserved_0x38
;
}
__attribute__
((
packed
));
/** "BOOT APP" magic signature */
#define BOOTAPP_SIGNATURE "BOOT APP"
/** Boot application descriptor version */
#define BOOTAPP_VERSION 2
/** i386 architecture */
#define BOOTAPP_ARCH_I386 0x014c
/** Memory region descriptor */
struct
bootapp_memory_region
{
/** Reserved (for struct list_head?) */
uint8_t
reserved
[
8
];
/** Start page address */
uint64_t
start_page
;
/** Reserved */
uint8_t
reserved_0x10
[
8
];
/** Number of pages */
uint64_t
num_pages
;
/** Reserved */
uint8_t
reserved_0x20
[
4
];
/** Flags */
uint32_t
flags
;
}
__attribute__
((
packed
));
/** Memory descriptor */
struct
bootapp_memory_descriptor
{
/** Version */
uint32_t
version
;
/** Length of descriptor (excluding region descriptors) */
uint32_t
len
;
/** Number of regions */
uint32_t
num_regions
;
/** Length of each region descriptor */
uint32_t
region_len
;
/** Length of reserved area at start of each region descriptor */
uint32_t
reserved_len
;
}
__attribute__
((
packed
));
/** Boot application memory descriptor version */
#define BOOTAPP_MEMORY_VERSION 1
/** Boot application entry descriptor */
struct
bootapp_entry_descriptor
{
/** Signature */
char
signature
[
8
];
/** Flags */
uint32_t
flags
;
/** GUID */
struct
guid
guid
;
/** Reserved */
uint8_t
reserved
[
16
];
}
__attribute__
((
packed
));
/** ??? */
struct
bootapp_entry_wtf1_descriptor
{
/** Flags */
uint32_t
flags
;
/** Length of descriptor */
uint32_t
len
;
/** Total length of following descriptors within BTAPENT */
uint32_t
extra_len
;
/** Reserved */
uint8_t
reserved
[
12
];
}
__attribute__
((
packed
));
/** ??? */
struct
bootapp_entry_wtf2_descriptor
{
/** GUID */
struct
guid
guid
;
}
__attribute__
((
packed
));
/** ??? */
struct
bootapp_entry_wtf3_descriptor
{
/** Flags */
uint32_t
flags
;
/** Reserved */
uint32_t
reserved_0x04
;
/** Length of descriptor */
uint32_t
len
;
/** Reserved */
uint32_t
reserved_0x0c
;
/** Boot partition offset (in bytes) */
uint32_t
boot_partition_offset
;
/** Reserved */
uint8_t
reserved_0x14
[
16
];
/** MBR signature present? */
uint32_t
xxx
;
/** MBR signature */
uint32_t
mbr_signature
;
/** Reserved */
uint8_t
reserved_0x2c
[
26
];
}
__attribute__
((
packed
));
/** "BTAPENT" magic signature */
#define BOOTAPP_ENTRY_SIGNATURE "BTAPENT\0"
/** Boot application entry flags
*
* pxeboot, etftboot, and fatboot all use a value of 0x21; I have no
* idea what it means.
*/
#define BOOTAPP_ENTRY_FLAGS 0x21
/** Boot application callback descriptor */
struct
bootapp_callback_descriptor
{
/** Real-mode callbacks */
struct
bootapp_callback
*
callback
;
/** Reserved */
uint32_t
reserved
;
}
__attribute__
((
packed
));
/** Boot application pointless descriptor */
struct
bootapp_pointless_descriptor
{
/** Version */
uint32_t
version
;
/** Reserved */
uint8_t
reserved
[
24
];
}
__attribute__
((
packed
));
/** Boot application pointless descriptor version */
#define BOOTAPP_POINTLESS_VERSION 1
#endif
/* _BOOTAPP_H */
wimboot/wimboot-2.7.3/src/byteswap.h
0 → 100644
View file @
93996cf7
#ifndef _BITS_BYTESWAP_H
#define _BITS_BYTESWAP_H
/** @file
*
* Byte-order swapping functions
*
*/
#include <stdint.h>
static
inline
__attribute__
((
always_inline
,
const
))
uint16_t
__bswap_variable_16
(
uint16_t
x
)
{
__asm__
(
"xchgb %b0,%h0"
:
"=Q"
(
x
)
:
"0"
(
x
)
);
return
x
;
}
static
inline
__attribute__
((
always_inline
))
void
__bswap_16s
(
uint16_t
*
x
)
{
__asm__
(
"rorw $8, %0"
:
"+m"
(
*
x
)
);
}
static
inline
__attribute__
((
always_inline
,
const
))
uint32_t
__bswap_variable_32
(
uint32_t
x
)
{
__asm__
(
"bswapl %k0"
:
"=r"
(
x
)
:
"0"
(
x
)
);
return
x
;
}
static
inline
__attribute__
((
always_inline
))
void
__bswap_32s
(
uint32_t
*
x
)
{
__asm__
(
"bswapl %k0"
:
"=r"
(
*
x
)
:
"0"
(
*
x
)
);
}
#ifdef __x86_64__
static
inline
__attribute__
((
always_inline
,
const
))
uint64_t
__bswap_variable_64
(
uint64_t
x
)
{
__asm__
(
"bswapq %q0"
:
"=r"
(
x
)
:
"0"
(
x
)
);
return
x
;
}
#else
/* __x86_64__ */
static
inline
__attribute__
((
always_inline
,
const
))
uint64_t
__bswap_variable_64
(
uint64_t
x
)
{
uint32_t
in_high
=
(
x
>>
32
);
uint32_t
in_low
=
(
x
&
0xffffffffUL
);
uint32_t
out_high
;
uint32_t
out_low
;
__asm__
(
"bswapl %0
\n\t
"
"bswapl %1
\n\t
"
"xchgl %0,%1
\n\t
"
:
"=r"
(
out_high
),
"=r"
(
out_low
)
:
"0"
(
in_high
),
"1"
(
in_low
)
);
return
(
(
(
(
uint64_t
)
out_high
)
<<
32
)
|
(
(
uint64_t
)
out_low
)
);
}
#endif
/* __x86_64__ */
static
inline
__attribute__
((
always_inline
))
void
__bswap_64s
(
uint64_t
*
x
)
{
*
x
=
__bswap_variable_64
(
*
x
);
}
/**
* Byte-swap a 16-bit constant
*
* @v value Constant value
* @ret swapped Byte-swapped value
*/
#define __bswap_constant_16( value ) \
( ( ( (value) & 0x00ff ) << 8 ) | \
( ( (value) & 0xff00 ) >> 8 ) )
/**
* Byte-swap a 32-bit constant
*
* @v value Constant value
* @ret swapped Byte-swapped value
*/
#define __bswap_constant_32( value ) \
( ( ( (value) & 0x000000ffUL ) << 24 ) | \
( ( (value) & 0x0000ff00UL ) << 8 ) | \
( ( (value) & 0x00ff0000UL ) >> 8 ) | \
( ( (value) & 0xff000000UL ) >> 24 ) )
/**
* Byte-swap a 64-bit constant
*
* @v value Constant value
* @ret swapped Byte-swapped value
*/
#define __bswap_constant_64( value ) \
( ( ( (value) & 0x00000000000000ffULL ) << 56 ) | \
( ( (value) & 0x000000000000ff00ULL ) << 40 ) | \
( ( (value) & 0x0000000000ff0000ULL ) << 24 ) | \
( ( (value) & 0x00000000ff000000ULL ) << 8 ) | \
( ( (value) & 0x000000ff00000000ULL ) >> 8 ) | \
( ( (value) & 0x0000ff0000000000ULL ) >> 24 ) | \
( ( (value) & 0x00ff000000000000ULL ) >> 40 ) | \
( ( (value) & 0xff00000000000000ULL ) >> 56 ) )
/**
* Byte-swap a 16-bit value
*
* @v value Value
* @ret swapped Byte-swapped value
*/
#define __bswap_16( value ) \
( __builtin_constant_p (value) ? \
( ( uint16_t ) __bswap_constant_16 ( ( uint16_t ) (value) ) ) \
: __bswap_variable_16 (value) )
#define bswap_16( value ) __bswap_16 (value)
/**
* Byte-swap a 32-bit value
*
* @v value Value
* @ret swapped Byte-swapped value
*/
#define __bswap_32( value ) \
( __builtin_constant_p (value) ? \
( ( uint32_t ) __bswap_constant_32 ( ( uint32_t ) (value) ) ) \
: __bswap_variable_32 (value) )
#define bswap_32( value ) __bswap_32 (value)
/**
* Byte-swap a 64-bit value
*
* @v value Value
* @ret swapped Byte-swapped value
*/
#define __bswap_64( value ) \
( __builtin_constant_p (value) ? \
( ( uint64_t ) __bswap_constant_64 ( ( uint64_t ) (value) ) ) \
: __bswap_variable_64 (value) )
#define bswap_64( value ) __bswap_64 (value)
#define __cpu_to_leNN( bits, value ) (value)
#define __cpu_to_beNN( bits, value ) __bswap_ ## bits (value)
#define __leNN_to_cpu( bits, value ) (value)
#define __beNN_to_cpu( bits, value ) __bswap_ ## bits (value)
#define __cpu_to_leNNs( bits, ptr ) do { } while ( 0 )
#define __cpu_to_beNNs( bits, ptr ) __bswap_ ## bits ## s (ptr)
#define __leNN_to_cpus( bits, ptr ) do { } while ( 0 )
#define __beNN_to_cpus( bits, ptr ) __bswap_ ## bits ## s (ptr)
#define cpu_to_le16( value ) __cpu_to_leNN ( 16, value )
#define cpu_to_le32( value ) __cpu_to_leNN ( 32, value )
#define cpu_to_le64( value ) __cpu_to_leNN ( 64, value )
#define cpu_to_be16( value ) __cpu_to_beNN ( 16, value )
#define cpu_to_be32( value ) __cpu_to_beNN ( 32, value )
#define cpu_to_be64( value ) __cpu_to_beNN ( 64, value )
#define le16_to_cpu( value ) __leNN_to_cpu ( 16, value )
#define le32_to_cpu( value ) __leNN_to_cpu ( 32, value )
#define le64_to_cpu( value ) __leNN_to_cpu ( 64, value )
#define be16_to_cpu( value ) __beNN_to_cpu ( 16, value )
#define be32_to_cpu( value ) __beNN_to_cpu ( 32, value )
#define be64_to_cpu( value ) __beNN_to_cpu ( 64, value )
#define cpu_to_le16s( ptr ) __cpu_to_leNNs ( 16, ptr )
#define cpu_to_le32s( ptr ) __cpu_to_leNNs ( 32, ptr )
#define cpu_to_le64s( ptr ) __cpu_to_leNNs ( 64, ptr )
#define cpu_to_be16s( ptr ) __cpu_to_beNNs ( 16, ptr )
#define cpu_to_be32s( ptr ) __cpu_to_beNNs ( 32, ptr )
#define cpu_to_be64s( ptr ) __cpu_to_beNNs ( 64, ptr )
#define le16_to_cpus( ptr ) __leNN_to_cpus ( 16, ptr )
#define le32_to_cpus( ptr ) __leNN_to_cpus ( 32, ptr )
#define le64_to_cpus( ptr ) __leNN_to_cpus ( 64, ptr )
#define be16_to_cpus( ptr ) __beNN_to_cpus ( 16, ptr )
#define be32_to_cpus( ptr ) __beNN_to_cpus ( 32, ptr )
#define be64_to_cpus( ptr ) __beNN_to_cpus ( 64, ptr )
#define htonll( value ) cpu_to_be64 (value)
#define ntohll( value ) be64_to_cpu (value)
#define htonl( value ) cpu_to_be32 (value)
#define ntohl( value ) be32_to_cpu (value)
#define htons( value ) cpu_to_be16 (value)
#define ntohs( value ) be16_to_cpu (value)
#endif
/* _BITS_BYTESWAP_H */
wimboot/wimboot-2.7.3/src/cmdline.c
0 → 100644
View file @
93996cf7
/*
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Command line
*
*/
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "wimboot.h"
#include "cmdline.h"
/** Use raw (unpatched) BCD files */
int
cmdline_rawbcd
;
/** Use raw (unpatched) WIM files */
int
cmdline_rawwim
;
/** Inhibit debugging output */
int
cmdline_quiet
;
/** Allow graphical output from bootmgr/bootmgfw */
int
cmdline_gui
;
/** Pause before booting OS */
int
cmdline_pause
;
/** Pause without displaying any prompt */
int
cmdline_pause_quiet
;
/** Use linear (unpaged) memory model */
int
cmdline_linear
;
/** WIM boot index */
unsigned
int
cmdline_index
;
int
cmdline_vf_num
;
char
cmdline_vf_path
[
MAX_VF
][
64
];
file_size_pf
pfventoy_file_size
;
file_read_pf
pfventoy_file_read
;
/**
* Process command line
*
* @v cmdline Command line
*/
void
process_cmdline
(
char
*
cmdline
)
{
char
*
tmp
=
cmdline
;
char
*
key
;
char
*
value
;
char
*
endp
;
/* Do nothing if we have no command line */
if
(
(
cmdline
==
NULL
)
||
(
cmdline
[
0
]
==
'\0'
)
)
return
;
/* Parse command line */
while
(
*
tmp
)
{
/* Skip whitespace */
while
(
isspace
(
*
tmp
)
)
tmp
++
;
/* Find value (if any) and end of this argument */
key
=
tmp
;
value
=
NULL
;
while
(
*
tmp
)
{
if
(
isspace
(
*
tmp
)
)
{
*
(
tmp
++
)
=
'\0'
;
break
;
}
else
if
(
*
tmp
==
'='
)
{
*
(
tmp
++
)
=
'\0'
;
value
=
tmp
;
}
else
{
tmp
++
;
}
}
/* Process this argument */
if
(
strcmp
(
key
,
"rawbcd"
)
==
0
)
{
cmdline_rawbcd
=
1
;
}
else
if
(
strcmp
(
key
,
"rawwim"
)
==
0
)
{
cmdline_rawwim
=
1
;
}
else
if
(
strcmp
(
key
,
"gui"
)
==
0
)
{
cmdline_gui
=
1
;
}
else
if
((
key
[
0
]
==
'v'
)
&&
(
key
[
1
]
==
'f'
)
)
{
if
(
cmdline_vf_num
>=
MAX_VF
)
die
(
"Too many vf
\n
"
);
snprintf
(
cmdline_vf_path
[
cmdline_vf_num
],
64
,
"%s"
,
value
);
cmdline_vf_num
++
;
}
else
if
(
strcmp
(
key
,
"pfsize"
)
==
0
)
{
pfventoy_file_size
=
(
file_size_pf
)
strtoul
(
value
,
&
endp
,
0
);
}
else
if
(
strcmp
(
key
,
"pfread"
)
==
0
)
{
pfventoy_file_read
=
(
file_read_pf
)
strtoul
(
value
,
&
endp
,
0
);
}
else
if
(
strcmp
(
key
,
"linear"
)
==
0
)
{
cmdline_linear
=
1
;
}
else
if
(
strcmp
(
key
,
"quiet"
)
==
0
)
{
cmdline_quiet
=
1
;
}
else
if
(
strcmp
(
key
,
"pause"
)
==
0
)
{
cmdline_pause
=
1
;
if
(
value
&&
(
strcmp
(
value
,
"quiet"
)
==
0
)
)
cmdline_pause_quiet
=
1
;
}
else
if
(
strcmp
(
key
,
"index"
)
==
0
)
{
if
(
(
!
value
)
||
(
!
value
[
0
]
)
)
die
(
"Argument
\"
index
\"
needs a value
\n
"
);
cmdline_index
=
strtoul
(
value
,
&
endp
,
0
);
if
(
*
endp
)
die
(
"Invalid index
\"
%s
\"\n
"
,
value
);
}
else
if
(
strcmp
(
key
,
"initrdfile"
)
==
0
)
{
/* Ignore this keyword to allow for use with syslinux */
}
else
if
(
key
==
cmdline
)
{
/* Ignore unknown initial arguments, which may
* be the program name.
*/
}
else
{
die
(
"Unrecognised argument
\"
%s%s%s
\"\n
"
,
key
,
(
value
?
"="
:
""
),
(
value
?
value
:
""
)
);
}
}
/* Show command line (after parsing "quiet" option) */
DBG
(
"Command line:
\"
%s
\"
vf=%d pfsize=%p pfread=%p
\n
"
,
cmdline
,
cmdline_vf_num
,
pfventoy_file_size
,
pfventoy_file_read
);
}
wimboot/wimboot-2.7.3/src/cmdline.h
0 → 100644
View file @
93996cf7
#ifndef _CMDLINE_H
#define _CMDLINE_H
/*
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Command line
*
*/
extern
int
cmdline_rawbcd
;
extern
int
cmdline_rawwim
;
extern
int
cmdline_quiet
;
extern
int
cmdline_gui
;
extern
int
cmdline_pause
;
extern
int
cmdline_pause_quiet
;
extern
int
cmdline_linear
;
extern
unsigned
int
cmdline_index
;
extern
void
process_cmdline
(
char
*
cmdline
);
typedef
int
(
*
file_size_pf
)(
const
char
*
path
);
typedef
int
(
*
file_read_pf
)(
const
char
*
path
,
int
offset
,
int
len
,
void
*
buf
);
extern
file_size_pf
pfventoy_file_size
;
extern
file_read_pf
pfventoy_file_read
;
#define MAX_VF 16
extern
char
cmdline_vf_path
[
MAX_VF
][
64
];
extern
int
cmdline_vf_num
;
#endif
/* _CMDLINE_H */
wimboot/wimboot-2.7.3/src/compiler.h
0 → 100644
View file @
93996cf7
#ifndef _COMPILER_H
#define _COMPILER_H
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Global compiler definitions
*
*/
/* Force visibility of all symbols to "hidden", i.e. inform gcc that
* all symbol references resolve strictly within our final binary.
* This avoids unnecessary PLT/GOT entries on x86_64.
*
* This is a stronger claim than specifying "-fvisibility=hidden",
* since it also affects symbols marked with "extern".
*/
#ifndef ASSEMBLY
#if __GNUC__ >= 4
#pragma GCC visibility push(hidden)
#endif
#endif
/* ASSEMBLY */
#endif
/* _COMPILER_H */
wimboot/wimboot-2.7.3/src/cookie.c
0 → 100644
View file @
93996cf7
/*
* Copyright (C) 2021 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Stack cookie
*
*/
#include "wimboot.h"
/** Stack cookie */
unsigned
long
__stack_chk_guard
;
/**
* Construct stack cookie value
*
*/
static
__attribute__
((
noinline
))
unsigned
long
make_cookie
(
void
)
{
union
{
struct
{
uint32_t
eax
;
uint32_t
edx
;
}
__attribute__
((
packed
));
unsigned
long
tsc
;
}
u
;
unsigned
long
cookie
;
/* We have no viable source of entropy. Use the CPU timestamp
* counter, which will have at least some minimal randomness
* in the low bits by the time we are invoked.
*/
__asm__
(
"rdtsc"
:
"=a"
(
u
.
eax
),
"=d"
(
u
.
edx
)
);
cookie
=
u
.
tsc
;
/* Ensure that the value contains a NUL byte, to act as a
* runaway string terminator. Construct the NUL using a shift
* rather than a mask, to avoid losing valuable entropy in the
* lower-order bits.
*/
cookie
<<=
8
;
return
cookie
;
}
/**
* Initialise stack cookie
*
* This function must not itself use stack guard
*/
void
init_cookie
(
void
)
{
/* Set stack cookie value
*
* This function must not itself use stack protection, since
* the change in the stack guard value would trigger a false
* positive.
*
* There is unfortunately no way to annotate a function to
* exclude the use of stack protection. We must therefore
* rely on correctly anticipating the compiler's decision on
* the use of stack protection.
*/
__stack_chk_guard
=
make_cookie
();
}
/**
* Abort on stack check failure
*
*/
void
__stack_chk_fail
(
void
)
{
/* Abort program */
die
(
"Stack check failed
\n
"
);
}
wimboot/wimboot-2.7.3/src/coverity-model.c
0 → 100644
View file @
93996cf7
/*
* Coverity modelling file
*
*/
typedef
unsigned
short
wchar_t
;
typedef
void
mbstate_t
;
/* Inhibit use of built-in models for functions where Coverity's
* assumptions about the modelled function are incorrect for wimboot.
*/
int
getchar
(
void
)
{
}
size_t
wcrtomb
(
char
*
buf
,
wchar_t
wc
,
mbstate_t
*
ps
)
{
}
wimboot/wimboot-2.7.3/src/cpio.c
0 → 100644
View file @
93996cf7
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* CPIO archives
*
*/
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "wimboot.h"
#include "cpio.h"
/**
* Align CPIO length to nearest dword
*
* @v len Length
* @ret len Aligned length
*/
static
size_t
cpio_align
(
size_t
len
)
{
return
(
(
len
+
0x03
)
&
~
0x03
);
}
/**
* Parse CPIO field value
*
* @v field ASCII field
* @ret value Field value
*/
static
unsigned
long
cpio_value
(
const
char
*
field
)
{
char
buf
[
9
];
memcpy
(
buf
,
field
,
(
sizeof
(
buf
)
-
1
)
);
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
return
strtoul
(
buf
,
NULL
,
16
);
}
/**
* Extract files from CPIO archive
*
* @v data CPIO archive
* @v len Maximum length of CPIO archive
* @v file File handler
* @ret rc Return status code
*/
int
cpio_extract
(
void
*
data
,
size_t
len
,
int
(
*
file
)
(
const
char
*
name
,
void
*
data
,
size_t
len
)
)
{
const
struct
cpio_header
*
cpio
;
const
uint32_t
*
pad
;
const
char
*
file_name
;
void
*
file_data
;
size_t
file_name_len
;
size_t
file_len
;
size_t
cpio_len
;
int
rc
;
while
(
1
)
{
/* Skip over any padding */
while
(
len
>=
sizeof
(
*
pad
)
)
{
pad
=
data
;
if
(
*
pad
)
break
;
data
+=
sizeof
(
*
pad
);
len
-=
sizeof
(
*
pad
);
}
/* Stop if we have reached the end of the archive */
if
(
!
len
)
return
0
;
/* Sanity check */
if
(
len
<
sizeof
(
*
cpio
)
)
{
DBG
(
"Truncated CPIO header
\n
"
);
return
-
1
;
}
cpio
=
data
;
/* Check magic */
if
(
memcmp
(
cpio
->
c_magic
,
CPIO_MAGIC
,
sizeof
(
cpio
->
c_magic
)
)
!=
0
)
{
DBG
(
"Bad CPIO magic
\n
"
);
return
-
1
;
}
/* Extract file parameters */
file_name
=
(
(
void
*
)
(
cpio
+
1
)
);
file_name_len
=
cpio_value
(
cpio
->
c_namesize
);
file_data
=
(
data
+
cpio_align
(
sizeof
(
*
cpio
)
+
file_name_len
)
);
file_len
=
cpio_value
(
cpio
->
c_filesize
);
cpio_len
=
(
file_data
+
file_len
-
data
);
if
(
cpio_len
<
len
)
cpio_len
=
cpio_align
(
cpio_len
);
if
(
cpio_len
>
len
)
{
DBG
(
"Truncated CPIO file
\n
"
);
return
-
1
;
}
/* If we reach the trailer, we're done */
if
(
strcmp
(
file_name
,
CPIO_TRAILER
)
==
0
)
return
0
;
/* Process file */
if
(
(
rc
=
file
(
file_name
,
file_data
,
file_len
)
)
!=
0
)
return
rc
;
/* Move to next file */
data
+=
cpio_len
;
len
-=
cpio_len
;
}
}
wimboot/wimboot-2.7.3/src/cpio.h
0 → 100644
View file @
93996cf7
#ifndef _CPIO_H
#define _CPIO_H
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* CPIO archives
*
*/
#include <stdint.h>
/** A CPIO archive header
*
* All field are hexadecimal ASCII numbers padded with '0' on the
* left to the full width of the field.
*/
struct
cpio_header
{
/** The string "070701" or "070702" */
char
c_magic
[
6
];
/** File inode number */
char
c_ino
[
8
];
/** File mode and permissions */
char
c_mode
[
8
];
/** File uid */
char
c_uid
[
8
];
/** File gid */
char
c_gid
[
8
];
/** Number of links */
char
c_nlink
[
8
];
/** Modification time */
char
c_mtime
[
8
];
/** Size of data field */
char
c_filesize
[
8
];
/** Major part of file device number */
char
c_maj
[
8
];
/** Minor part of file device number */
char
c_min
[
8
];
/** Major part of device node reference */
char
c_rmaj
[
8
];
/** Minor part of device node reference */
char
c_rmin
[
8
];
/** Length of filename, including final NUL */
char
c_namesize
[
8
];
/** Checksum of data field if c_magic is 070702, othersize zero */
char
c_chksum
[
8
];
}
__attribute__
((
packed
));
/** CPIO magic */
#define CPIO_MAGIC "070701"
/** CPIO trailer */
#define CPIO_TRAILER "TRAILER!!!"
extern
int
cpio_extract
(
void
*
data
,
size_t
len
,
int
(
*
file
)
(
const
char
*
name
,
void
*
data
,
size_t
len
)
);
#endif
/* _CPIO_H */
wimboot/wimboot-2.7.3/src/ctype.h
0 → 100644
View file @
93996cf7
#ifndef _CTYPE_H
#define _CTYPE_H
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Character types
*
*/
static
inline
int
islower
(
int
c
)
{
return
(
(
c
>=
'a'
)
&&
(
c
<=
'z'
)
);
}
static
inline
int
isupper
(
int
c
)
{
return
(
(
c
>=
'A'
)
&&
(
c
<=
'Z'
)
);
}
static
inline
int
toupper
(
int
c
)
{
if
(
islower
(
c
)
)
c
-=
(
'a'
-
'A'
);
return
c
;
}
extern
int
isspace
(
int
c
);
#endif
/* _CTYPE_H */
wimboot/wimboot-2.7.3/src/die.c
0 → 100644
View file @
93996cf7
/*
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* Fatal errors
*
*/
#include <stdarg.h>
#include <stdio.h>
#include "wimboot.h"
#include "efi.h"
/**
* Handle fatal errors
*
* @v fmt Error message format string
* @v ... Arguments
*/
void
die
(
const
char
*
fmt
,
...
)
{
EFI_BOOT_SERVICES
*
bs
;
EFI_RUNTIME_SERVICES
*
rs
;
va_list
args
;
/* Print message */
va_start
(
args
,
fmt
);
vprintf
(
fmt
,
args
);
va_end
(
args
);
/* Reboot or exit as applicable */
if
(
efi_systab
)
{
/* Exit */
bs
=
efi_systab
->
BootServices
;
bs
->
Exit
(
efi_image_handle
,
EFI_LOAD_ERROR
,
0
,
NULL
);
printf
(
"Failed to exit
\n
"
);
rs
=
efi_systab
->
RuntimeServices
;
rs
->
ResetSystem
(
EfiResetWarm
,
0
,
0
,
NULL
);
printf
(
"Failed to reboot
\n
"
);
}
else
{
/* Wait for keypress */
printf
(
"Press a key to reboot..."
);
getchar
();
printf
(
"
\n
"
);
/* Reboot system */
reboot
();
}
/* Should be impossible to reach this */
__builtin_unreachable
();
}
wimboot/wimboot-2.7.3/src/efi.c
0 → 100644
View file @
93996cf7
/*
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* EFI interface
*
*/
#include "wimboot.h"
#include "efi.h"
/** EFI system table */
EFI_SYSTEM_TABLE
*
efi_systab
;
/** EFI image handle */
EFI_HANDLE
efi_image_handle
;
wimboot/wimboot-2.7.3/src/efi.h
0 → 100644
View file @
93996cf7
#ifndef _EFI_H
#define _EFI_H
/*
* Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
/**
* @file
*
* EFI definitions
*
*/
/* EFIAPI definition */
#if __x86_64__
#define EFIAPI __attribute__ (( ms_abi ))
#else
#define EFIAPI
#endif
/* EFI headers rudely redefine NULL */
#undef NULL
#include "efi/Uefi.h"
#include "efi/Protocol/LoadedImage.h"
extern
EFI_SYSTEM_TABLE
*
efi_systab
;
extern
EFI_HANDLE
efi_image_handle
;
extern
EFI_GUID
efi_block_io_protocol_guid
;
extern
EFI_GUID
efi_device_path_protocol_guid
;
extern
EFI_GUID
efi_graphics_output_protocol_guid
;
extern
EFI_GUID
efi_loaded_image_protocol_guid
;
extern
EFI_GUID
efi_simple_file_system_protocol_guid
;
#endif
/* _EFI_H */
wimboot/wimboot-2.7.3/src/efi/Base.h
0 → 100644
View file @
93996cf7
This diff is collapsed.
Click to expand it.
wimboot/wimboot-2.7.3/src/efi/Guid/FileInfo.h
0 → 100644
View file @
93996cf7
/** @file
Provides a GUID and a data structure that can be used with EFI_FILE_PROTOCOL.SetInfo()
and EFI_FILE_PROTOCOL.GetInfo() to set or get generic file information.
This GUID is defined in UEFI specification.
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __FILE_INFO_H__
#define __FILE_INFO_H__
#define EFI_FILE_INFO_ID \
{ \
0x9576e92, 0x6d3f, 0x11d2, {0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
}
typedef
struct
{
///
/// The size of the EFI_FILE_INFO structure, including the Null-terminated FileName string.
///
UINT64
Size
;
///
/// The size of the file in bytes.
///
UINT64
FileSize
;
///
/// PhysicalSize The amount of physical space the file consumes on the file system volume.
///
UINT64
PhysicalSize
;
///
/// The time the file was created.
///
EFI_TIME
CreateTime
;
///
/// The time when the file was last accessed.
///
EFI_TIME
LastAccessTime
;
///
/// The time when the file's contents were last modified.
///
EFI_TIME
ModificationTime
;
///
/// The attribute bits for the file.
///
UINT64
Attribute
;
///
/// The Null-terminated name of the file.
///
CHAR16
FileName
[
1
];
}
EFI_FILE_INFO
;
///
/// The FileName field of the EFI_FILE_INFO data structure is variable length.
/// Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to
/// be the size of the data structure without the FileName field. The following macro
/// computes this size correctly no matter how big the FileName array is declared.
/// This is required to make the EFI_FILE_INFO data structure ANSI compilant.
///
#define SIZE_OF_EFI_FILE_INFO OFFSET_OF (EFI_FILE_INFO, FileName)
extern
EFI_GUID
gEfiFileInfoGuid
;
#endif
wimboot/wimboot-2.7.3/src/efi/Guid/HiiFormMapMethodGuid.h
0 → 100644
View file @
93996cf7
/** @file
Guid used to identify HII FormMap configuration method.
Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
GUID defined in UEFI 2.2 spec.
**/
#ifndef __EFI_HII_FORMMAP_GUID_H__
#define __EFI_HII_FORMMAP_GUID_H__
#define EFI_HII_STANDARD_FORM_GUID \
{ 0x3bd2f4ec, 0xe524, 0x46e4, { 0xa9, 0xd8, 0x51, 0x1, 0x17, 0x42, 0x55, 0x62 } }
extern
EFI_GUID
gEfiHiiStandardFormGuid
;
#endif
wimboot/wimboot-2.7.3/src/efi/Guid/PcAnsi.h
0 → 100644
View file @
93996cf7
/** @file
Terminal Device Path Vendor Guid.
Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
GUIDs defined in UEFI 2.0 spec.
**/
#ifndef __PC_ANSI_H__
#define __PC_ANSI_H__
#define EFI_PC_ANSI_GUID \
{ \
0xe0c14753, 0xf9be, 0x11d2, {0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
}
#define EFI_VT_100_GUID \
{ \
0xdfa66065, 0xb419, 0x11d3, {0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \
}
#define EFI_VT_100_PLUS_GUID \
{ \
0x7baec70b, 0x57e0, 0x4c76, {0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 } \
}
#define EFI_VT_UTF8_GUID \
{ \
0xad15a0d6, 0x8bec, 0x4acf, {0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 } \
}
#define DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL \
{ \
0x37499a9d, 0x542f, 0x4c89, {0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 } \
}
#define EFI_SAS_DEVICE_PATH_GUID \
{ \
0xd487ddb4, 0x008b, 0x11d9, {0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } \
}
extern
EFI_GUID
gEfiPcAnsiGuid
;
extern
EFI_GUID
gEfiVT100Guid
;
extern
EFI_GUID
gEfiVT100PlusGuid
;
extern
EFI_GUID
gEfiVTUTF8Guid
;
extern
EFI_GUID
gEfiUartDevicePathGuid
;
extern
EFI_GUID
gEfiSasDevicePathGuid
;
#endif
wimboot/wimboot-2.7.3/src/efi/Guid/WinCertificate.h
0 → 100644
View file @
93996cf7
/** @file
GUID for UEFI WIN_CERTIFICATE structure.
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
@par Revision Reference:
GUID defined in UEFI 2.0 spec.
**/
#ifndef __EFI_WIN_CERTIFICATE_H__
#define __EFI_WIN_CERTIFICATE_H__
//
// _WIN_CERTIFICATE.wCertificateType
//
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA 0x0002
#define WIN_CERT_TYPE_EFI_PKCS115 0x0EF0
#define WIN_CERT_TYPE_EFI_GUID 0x0EF1
///
/// The WIN_CERTIFICATE structure is part of the PE/COFF specification.
///
typedef
struct
{
///
/// The length of the entire certificate,
/// including the length of the header, in bytes.
///
UINT32
dwLength
;
///
/// The revision level of the WIN_CERTIFICATE
/// structure. The current revision level is 0x0200.
///
UINT16
wRevision
;
///
/// The certificate type. See WIN_CERT_TYPE_xxx for the UEFI
/// certificate types. The UEFI specification reserves the range of
/// certificate type values from 0x0EF0 to 0x0EFF.
///
UINT16
wCertificateType
;
///
/// The following is the actual certificate. The format of
/// the certificate depends on wCertificateType.
///
/// UINT8 bCertificate[ANYSIZE_ARRAY];
///
}
WIN_CERTIFICATE
;
///
/// WIN_CERTIFICATE_UEFI_GUID.CertType
///
#define EFI_CERT_TYPE_RSA2048_SHA256_GUID \
{0xa7717414, 0xc616, 0x4977, {0x94, 0x20, 0x84, 0x47, 0x12, 0xa7, 0x35, 0xbf } }
///
/// WIN_CERTIFICATE_UEFI_GUID.CertData
///
typedef
struct
{
EFI_GUID
HashType
;
UINT8
PublicKey
[
256
];
UINT8
Signature
[
256
];
}
EFI_CERT_BLOCK_RSA_2048_SHA256
;
///
/// Certificate which encapsulates a GUID-specific digital signature
///
typedef
struct
{
///
/// This is the standard WIN_CERTIFICATE header, where
/// wCertificateType is set to WIN_CERT_TYPE_EFI_GUID.
///
WIN_CERTIFICATE
Hdr
;
///
/// This is the unique id which determines the
/// format of the CertData. .
///
EFI_GUID
CertType
;
///
/// The following is the certificate data. The format of
/// the data is determined by the CertType.
/// If CertType is EFI_CERT_TYPE_RSA2048_SHA256_GUID,
/// the CertData will be EFI_CERT_BLOCK_RSA_2048_SHA256 structure.
///
UINT8
CertData
[
1
];
}
WIN_CERTIFICATE_UEFI_GUID
;
///
/// Certificate which encapsulates the RSASSA_PKCS1-v1_5 digital signature.
///
/// The WIN_CERTIFICATE_UEFI_PKCS1_15 structure is derived from
/// WIN_CERTIFICATE and encapsulate the information needed to
/// implement the RSASSA-PKCS1-v1_5 digital signature algorithm as
/// specified in RFC2437.
///
typedef
struct
{
///
/// This is the standard WIN_CERTIFICATE header, where
/// wCertificateType is set to WIN_CERT_TYPE_UEFI_PKCS1_15.
///
WIN_CERTIFICATE
Hdr
;
///
/// This is the hashing algorithm which was performed on the
/// UEFI executable when creating the digital signature.
///
EFI_GUID
HashAlgorithm
;
///
/// The following is the actual digital signature. The
/// size of the signature is the same size as the key
/// (1024-bit key is 128 bytes) and can be determined by
/// subtracting the length of the other parts of this header
/// from the total length of the certificate as found in
/// Hdr.dwLength.
///
/// UINT8 Signature[];
///
}
WIN_CERTIFICATE_EFI_PKCS1_15
;
extern
EFI_GUID
gEfiCertTypeRsa2048Sha256Guid
;
#endif
Prev
1
2
3
4
5
6
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment