Author: hbelusca
Date: Fri Jan 8 12:59:19 2016
New Revision: 70546
URL: http://svn.reactos.org/svn/reactos?rev=70546&view=rev
Log:
[FATTEN:FATFS]: Minor code reshuffling to make ease for syncing with future versions of the FatFS library (currently 0.11a).
Added:
trunk/reactos/tools/fatten/fatfs/00history.txt (with props)
Modified:
trunk/reactos/tools/fatten/fatfs/00readme.txt
trunk/reactos/tools/fatten/fatfs/diskio.c
trunk/reactos/tools/fatten/fatfs/diskio.h
trunk/reactos/tools/fatten/fatfs/ff.c
Added: trunk/reactos/tools/fatten/fatfs/00history.txt
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/00histo…
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/00history.txt (added)
+++ trunk/reactos/tools/fatten/fatfs/00history.txt [iso-8859-1] Fri Jan 8 12:59:19 2016
@@ -0,0 +1,245 @@
+----------------------------------------------------------------------------
+ Revision history of FatFs module
+----------------------------------------------------------------------------
+
+R0.00 (February 26, 2006)
+
+ Prototype.
+
+
+
+R0.01 (April 29, 2006)
+
+ First stable version.
+
+
+
+R0.02 (June 01, 2006)
+
+ Added FAT12 support.
+ Removed unbuffered mode.
+ Fixed a problem on small (<32M) partition.
+
+
+
+R0.02a (June 10, 2006)
+
+ Added a configuration option (_FS_MINIMUM).
+
+
+
+R0.03 (September 22, 2006)
+
+ Added f_rename().
+ Changed option _FS_MINIMUM to _FS_MINIMIZE.
+
+
+
+R0.03a (December 11, 2006)
+
+ Improved cluster scan algorithm to write files fast.
+ Fixed f_mkdir() creates incorrect directory on FAT32.
+
+
+
+R0.04 (February 04, 2007)
+
+ Added f_mkfs().
+ Supported multiple drive system.
+ Changed some interfaces for multiple drive system.
+ Changed f_mountdrv() to f_mount().
+
+
+
+R0.04a (April 01, 2007)
+
+ Supported multiple partitions on a physical drive.
+ Added a capability of extending file size to f_lseek().
+ Added minimization level 3.
+ Fixed an endian sensitive code in f_mkfs().
+
+
+
+R0.04b (May 05, 2007)
+
+ Added a configuration option _USE_NTFLAG.
+ Added FSINFO support.
+ Fixed DBCS name can result FR_INVALID_NAME.
+ Fixed short seek (<= csize) collapses the file object.
+
+
+
+R0.05 (August 25, 2007)
+
+ Changed arguments of f_read(), f_write() and f_mkfs().
+ Fixed f_mkfs() on FAT32 creates incorrect FSINFO.
+ Fixed f_mkdir() on FAT32 creates incorrect directory.
+
+
+
+R0.05a (February 03, 2008)
+
+ Added f_truncate() and f_utime().
+ Fixed off by one error at FAT sub-type determination.
+ Fixed btr in f_read() can be mistruncated.
+ Fixed cached sector is not flushed when create and close without write.
+
+
+
+R0.06 (April 01, 2008)
+
+ Added fputc(), fputs(), fprintf() and fgets().
+ Improved performance of f_lseek() on moving to the same or following cluster.
+
+
+
+R0.07 (April 01, 2009)
+
+ Merged Tiny-FatFs as a configuration option. (_FS_TINY)
+ Added long file name feature. (_USE_LFN)
+ Added multiple code page feature. (_CODE_PAGE)
+ Added re-entrancy for multitask operation. (_FS_REENTRANT)
+ Added auto cluster size selection to f_mkfs().
+ Added rewind option to f_readdir().
+ Changed result code of critical errors.
+ Renamed string functions to avoid name collision.
+
+
+
+R0.07a (April 14, 2009)
+
+ Septemberarated out OS dependent code on reentrant cfg.
+ Added multiple sector size feature.
+
+
+
+R0.07c (June 21, 2009)
+
+ Fixed f_unlink() can return FR_OK on error.
+ Fixed wrong cache control in f_lseek().
+ Added relative path feature.
+ Added f_chdir() and f_chdrive().
+ Added proper case conversion to extended character.
+
+
+
+R0.07e (November 03, 2009)
+
+ Septemberarated out configuration options from ff.h to ffconf.h.
+ Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH.
+ Fixed name matching error on the 13 character boundary.
+ Added a configuration option, _LFN_UNICODE.
+ Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
+
+
+
+R0.08 (May 15, 2010)
+
+ Added a memory configuration option. (_USE_LFN = 3)
+ Added file lock feature. (_FS_SHARE)
+ Added fast seek feature. (_USE_FASTSEEK)
+ Changed some types on the API, XCHAR->TCHAR.
+ Changed .fname in the FILINFO structure on Unicode cfg.
+ String functions support UTF-8 encoding files on Unicode cfg.
+
+
+
+R0.08a (August 16, 2010)
+
+ Added f_getcwd(). (_FS_RPATH = 2)
+ Added sector erase feature. (_USE_ERASE)
+ Moved file lock semaphore table from fs object to the bss.
+ Fixed f_mkfs() creates wrong FAT32 volume.
+
+
+
+R0.08b (January 15, 2011)
+
+ Fast seek feature is also applied to f_read() and f_write().
+ f_lseek() reports required table size on creating CLMP.
+ Extended format syntax of f_printf().
+ Ignores duplicated directory separators in given path name.
+
+
+
+R0.09 (September 06, 2011)
+
+ f_mkfs() supports multiple partition to complete the multiple partition feature.
+ Added f_fdisk().
+
+
+
+R0.09a (August 27, 2012)
+
+ Changed f_open() and f_opendir() reject null object pointer to avoid crash.
+ Changed option name _FS_SHARE to _FS_LOCK.
+ Fixed assertion failure due to OS/2 EA on FAT12/16 volume.
+
+
+
+R0.09b (January 24, 2013)
+
+ Added f_setlabel() and f_getlabel().
+
+
+
+R0.10 (October 02, 2013)
+
+ Added selection of character encoding on the file. (_STRF_ENCODE)
+ Added f_closedir().
+ Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
+ Added forced mount feature with changes of f_mount().
+ Improved behavior of volume auto detection.
+ Improved write throughput of f_puts() and f_printf().
+ Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
+ Fixed f_write() can be truncated when the file size is close to 4GB.
+ Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code.
+
+
+
+R0.10a (January 15, 2014)
+
+ Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
+ Added a configuration option of minimum sector size. (_MIN_SS)
+ 2nd argument of f_rename() can have a drive number and it will be ignored.
+ Fixed f_mount() with forced mount fails when drive number is >= 1. (appeared at R0.10)
+ Fixed f_close() invalidates the file object without volume lock.
+ Fixed f_closedir() returns but the volume lock is left acquired. (appeared at R0.10)
+ Fixed creation of an entry with LFN fails on too many SFN collisions. (appeared at R0.07)
+
+
+
+R0.10b (May 19, 2014)
+
+ Fixed a hard error in the disk I/O layer can collapse the directory entry.
+ Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN. (appeared at R0.07)
+
+
+
+R0.10c (November 09, 2014)
+
+ Added a configuration option for the platforms without RTC. (_FS_NORTC)
+ Changed option name _USE_ERASE to _USE_TRIM.
+ Fixed volume label created by Mac OS X cannot be retrieved with f_getlabel(). (appeared at R0.09b)
+ Fixed a potential problem of FAT access that can appear on disk error.
+ Fixed null pointer dereference on attempting to delete the root direcotry. (appeared at R0.08)
+
+
+
+R0.11 (February 09, 2015)
+
+ Added f_findfirst(), f_findnext() and f_findclose(). (_USE_FIND)
+ Fixed f_unlink() does not remove cluster chain of the file. (appeared at R0.10c)
+ Fixed _FS_NORTC option does not work properly. (appeared at R0.10c)
+
+
+
+R0.11a (September 05, 2015)
+
+ Fixed wrong media change can lead a deadlock at thread-safe configuration.
+ Added code page 771, 860, 861, 863, 864, 865 and 869. (_CODE_PAGE)
+ Removed some code pages actually not exist on the standard systems. (_CODE_PAGE)
+ Fixed errors in the case conversion teble of code page 437 and 850 (ff.c).
+ Fixed errors in the case conversion teble of Unicode (cc*.c).
+
+
Propchange: trunk/reactos/tools/fatten/fatfs/00history.txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/tools/fatten/fatfs/00readme.txt
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/00readm…
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/00readme.txt [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatfs/00readme.txt [iso-8859-1] Fri Jan 8 12:59:19 2016
@@ -1,155 +1,21 @@
-FatFs Module Source Files R0.10a (C)ChaN, 2014
+FatFs Module Source Files R0.11
FILES
- ffconf.h Configuration file for FatFs module.
- ff.h Common include file for FatFs and application module.
- ff.c FatFs module.
- diskio.h Common include file for FatFs and disk I/O module.
- diskio.c An example of glue function to attach existing disk I/O module to FatFs.
- integer.h Integer type definitions for FatFs.
- option Optional external functions.
+ 00readme.txt This file.
+ history.txt Revision history.
+ ffconf.h Configuration file for FatFs module.
+ ff.h Common include file for FatFs and application module.
+ ff.c FatFs module.
+ diskio.h Common include file for FatFs and disk I/O module.
+ diskio.c An example of glue function to attach existing disk I/O module to FatFs.
+ integer.h Integer type definitions for FatFs.
+ option Optional external functions.
+
Low level disk I/O module is not included in this archive because the FatFs
module is only a generic file system layer and not depend on any specific
storage device. You have to provide a low level disk I/O module that written
- to control your storage device.
+ to control the target storage device.
-
-
-AGREEMENTS
-
- FatFs module is an open source software to implement FAT file system to
- small embedded systems. This is a free software and is opened for education,
- research and commercial developments under license policy of following trems.
-
- Copyright (C) 2014, ChaN, all right reserved.
-
- * The FatFs module is a free software and there is NO WARRANTY.
- * No restriction on use. You can use, modify and redistribute it for
- personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
- * Redistributions of source code must retain the above copyright notice.
-
-
-
-REVISION HISTORY
-
- Feb 26, 2006 R0.00 Prototype
-
- Apr 29, 2006 R0.01 First release.
-
- Jun 01, 2006 R0.02 Added FAT12.
- Removed unbuffered mode.
- Fixed a problem on small (<32M) patition.
-
- Jun 10, 2006 R0.02a Added a configuration option _FS_MINIMUM.
-
- Sep 22, 2006 R0.03 Added f_rename.
- Changed option _FS_MINIMUM to _FS_MINIMIZE.
-
- Dec 11, 2006 R0.03a Improved cluster scan algolithm to write files fast.
- Fixed f_mkdir creates incorrect directory on FAT32.
-
- Feb 04, 2007 R0.04 Supported multiple drive system. (FatFs)
- Changed some APIs for multiple drive system.
- Added f_mkfs. (FatFs)
- Added _USE_FAT32 option. (Tiny-FatFs)
-
- Apr 01, 2007 R0.04a Supported multiple partitions on a plysical drive. (FatFs)
- Fixed an endian sensitive code in f_mkfs. (FatFs)
- Added a capability of extending the file size to f_lseek.
- Added minimization level 3.
- Fixed a problem that can collapse a sector when recreate an
- existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs)
-
- May 05, 2007 R0.04b Added _USE_NTFLAG option.
- Added FSInfo support.
- Fixed some problems corresponds to FAT32. (Tiny-FatFs)
- Fixed DBCS name can result FR_INVALID_NAME.
- Fixed short seek (0 < ofs <= csize) collapses the file object.
-
- Aug 25, 2007 R0.05 Changed arguments of f_read, f_write.
- Changed arguments of f_mkfs. (FatFs)
- Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs)
- Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
-
- Feb 03, 2008 R0.05a Added f_truncate().
- Added f_utime().
- Fixed off by one error at FAT sub-type determination.
- Fixed btr in f_read() can be mistruncated.
- Fixed cached sector is not flushed when create and close without write.
-
- Apr 01, 2008 R0.06 Added f_forward(). (Tiny-FatFs)
- Added string functions: fputc(), fputs(), fprintf() and fgets().
- Improved performance of f_lseek() on move to the same or following cluster.
-
- Apr 01, 2009, R0.07 Merged Tiny-FatFs as a buffer configuration option.
- Added long file name support.
- Added multiple code page support.
- Added re-entrancy for multitask operation.
- Added auto cluster size selection to f_mkfs().
- Added rewind option to f_readdir().
- Changed result code of critical errors.
- Renamed string functions to avoid name collision.
-
- Apr 14, 2009, R0.07a Separated out OS dependent code on reentrant cfg.
- Added multiple sector size support.
-
- Jun 21, 2009, R0.07c Fixed f_unlink() may return FR_OK on error.
- Fixed wrong cache control in f_lseek().
- Added relative path feature.
- Added f_chdir().
- Added f_chdrive().
- Added proper case conversion for extended characters.
-
- Nov 03, 2009 R0.07e Separated out configuration options from ff.h to ffconf.h.
- Added a configuration option, _LFN_UNICODE.
- Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
- Fixed name matching error on the 13 char boundary.
- Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
-
- May 15, 2010, R0.08 Added a memory configuration option. (_USE_LFN)
- Added file lock feature. (_FS_SHARE)
- Added fast seek feature. (_USE_FASTSEEK)
- Changed some types on the API, XCHAR->TCHAR.
- Changed fname member in the FILINFO structure on Unicode cfg.
- String functions support UTF-8 encoding files on Unicode cfg.
-
- Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
- Added sector erase feature. (_USE_ERASE)
- Moved file lock semaphore table from fs object to the bss.
- Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
- Fixed f_mkfs() creates wrong FAT32 volume.
-
- Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
- f_lseek() reports required table size on creating CLMP.
- Extended format syntax of f_printf function.
- Ignores duplicated directory separators in given path names.
-
- Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature.
- Added f_fdisk(). (_MULTI_PARTITION = 2)
-
- Aug 27,'12 R0.09a Fixed assertion failure due to OS/2 EA on FAT12/16.
- Changed f_open() and f_opendir() reject null object pointer to avoid crash.
- Changed option name _FS_SHARE to _FS_LOCK.
-
- Jan 23,'13 R0.09b Added f_getlabel() and f_setlabel(). (_USE_LABEL)
-
- Oct 02,'13 R0.10 Added selection of character encoding on the file. (_STRF_ENCODE)
- Added f_closedir().
- Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO)
- Added forced mount feature with changes of f_mount().
- Improved behavior of volume auto detection.
- Improved write throughput of f_puts() and f_printf().
- Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write().
- Fixed f_write() can be truncated when the file size is close to 4GB.
- Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code.
-
- Jan 15,'14 R0.10a Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID)
- Added a configuration option of minimum sector size. (_MIN_SS)
- 2nd argument of f_rename() can have a drive number and it will be ignored.
- Fixed f_mount() with forced mount fails when drive number is >= 1.
- Fixed f_close() invalidates the file object without volume lock.
- Fixed f_closedir() returns but the volume lock is left acquired.
- Fixed creation of an entry with LFN fails on too many SFN collisions.
Modified: trunk/reactos/tools/fatten/fatfs/diskio.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/diskio.…
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/diskio.c [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatfs/diskio.c [iso-8859-1] Fri Jan 8 12:59:19 2016
@@ -1,12 +1,13 @@
/*-----------------------------------------------------------------------*/
-/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */
+/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
/*-----------------------------------------------------------------------*/
/* If a working storage control module is available, it should be */
/* attached to the FatFs via a glue function rather than modifying it. */
/* This is an example of glue functions to attach various exsisting */
-/* storage control module to the FatFs module with a defined API. */
-/*-----------------------------------------------------------------------*/
-#include "diskio.h"
+/* storage control modules to the FatFs module with a defined API. */
+/*-----------------------------------------------------------------------*/
+
+#include "diskio.h" /* FatFs lower layer API */
#include <stdio.h>
/*-----------------------------------------------------------------------*/
Modified: trunk/reactos/tools/fatten/fatfs/diskio.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/diskio.…
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/diskio.h [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatfs/diskio.h [iso-8859-1] Fri Jan 8 12:59:19 2016
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------/
-/ Low level disk interface modlue include file (C)ChaN, 2013 /
+/ Low level disk interface modlue include file (C)ChaN, 2014 /
/-----------------------------------------------------------------------*/
#ifndef _DISKIO_DEFINED
@@ -50,12 +50,12 @@
/* Command code for disk_ioctrl fucntion */
-/* Generic command (used by FatFs) */
-#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
-#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
-#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
-#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
-#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
+/* Generic command (Used by FatFs) */
+#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
+#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
+#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
+#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
+#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
/* Custom command for image file resizing */
#define SET_SECTOR_COUNT 126
Modified: trunk/reactos/tools/fatten/fatfs/ff.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/fatten/fatfs/ff.c?re…
==============================================================================
--- trunk/reactos/tools/fatten/fatfs/ff.c [iso-8859-1] (original)
+++ trunk/reactos/tools/fatten/fatfs/ff.c [iso-8859-1] Fri Jan 8 12:59:19 2016
@@ -4056,8 +4056,8 @@
/*-----------------------------------------------------------------------*/
/* Create file system on the logical drive */
/*-----------------------------------------------------------------------*/
-#define N_ROOTDIR12 224 /* Number of root directory entries for FAT12/16 */
-#define N_ROOTDIR16 512 /* Number of root directory entries for FAT12/16 */
+#define N_ROOTDIR12 224 /* Number of root directory entries for FAT12 */
+#define N_ROOTDIR16 512 /* Number of root directory entries for FAT16 */
#define N_FATS 2 /* Number of FATs (1 or 2) */
@@ -4141,10 +4141,10 @@
n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4;
n_fat = (n_fat + SS(fs) - 1) / SS(fs);
n_rsv = 1;
- if(fmt == FS_FAT12)
- n_dir = (DWORD)N_ROOTDIR12 * SZ_DIRE / SS(fs);
- else
- n_dir = (DWORD)N_ROOTDIR16 * SZ_DIRE / SS(fs);
+ if (fmt == FS_FAT12)
+ n_dir = (DWORD)N_ROOTDIR12 * SZ_DIRE / SS(fs);
+ else
+ n_dir = (DWORD)N_ROOTDIR16 * SZ_DIRE / SS(fs);
}
b_fat = b_vol + n_rsv; /* FAT area start sector */
b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */
@@ -4226,20 +4226,11 @@
ST_DWORD(tbl + BPB_TotSec32, n_vol);
}
tbl[BPB_Media] = md; /* Media descriptor */
- ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */
+ ST_DWORD(tbl + BPB_HiddSec, b_vol); /* Hidden sectors */
n = GET_FATTIME(); /* Use current time as VSN */
- if (fmt == FS_FAT12) {
- /* Assume floppy characteristics */
- ST_WORD(tbl + BPB_SecPerTrk, 0x12); /* Number of sectors per track */
- ST_WORD(tbl + BPB_NumHeads, 0x02); /* Number of heads */
- ST_DWORD(tbl + BS_VolID, n); /* VSN */
- ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */
- tbl[BS_DrvNum] = 0x00; /* Drive number */
- tbl[BS_BootSig] = 0x29; /* Extended boot signature */
- mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT12 ", 19); /* Volume label, FAT signature */
- } else if (fmt == FS_FAT32) {
- ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */
- ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */
+ if (fmt == FS_FAT32) {
+ ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */
+ ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */
ST_DWORD(tbl + BS_VolID32, n); /* VSN */
ST_DWORD(tbl + BPB_FATSz32, n_fat); /* Number of sectors per FAT */
ST_DWORD(tbl + BPB_RootClus, 2); /* Root directory start cluster (2) */
@@ -4248,15 +4239,24 @@
tbl[BS_DrvNum32] = 0x80; /* Drive number */
tbl[BS_BootSig32] = 0x29; /* Extended boot signature */
mem_cpy(tbl + BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */
- } else {
- ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */
- ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */
- ST_DWORD(tbl + BS_VolID, n); /* VSN */
- ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */
- tbl[BS_DrvNum] = 0x80; /* Drive number */
- tbl[BS_BootSig] = 0x29; /* Extended boot signature */
- mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */
- }
+ } else if (fmt == FS_FAT16) {
+ ST_WORD(tbl + BPB_SecPerTrk, 63); /* Number of sectors per track */
+ ST_WORD(tbl + BPB_NumHeads, 255); /* Number of heads */
+ ST_DWORD(tbl + BS_VolID, n); /* VSN */
+ ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */
+ tbl[BS_DrvNum] = 0x80; /* Drive number */
+ tbl[BS_BootSig] = 0x29; /* Extended boot signature */
+ mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT16 ", 19); /* Volume label, FAT signature */
+ } else /* if (fmt == FS_FAT12) */ {
+ /* Assume floppy characteristics */
+ ST_WORD(tbl + BPB_SecPerTrk, 0x12); /* Number of sectors per track */
+ ST_WORD(tbl + BPB_NumHeads, 0x02); /* Number of heads */
+ ST_DWORD(tbl + BS_VolID, n); /* VSN */
+ ST_WORD(tbl + BPB_FATSz16, n_fat); /* Number of sectors per FAT */
+ tbl[BS_DrvNum] = 0x00; /* Drive number */
+ tbl[BS_BootSig] = 0x29; /* Extended boot signature */
+ mem_cpy(tbl + BS_VolLab, "NO NAME " "FAT12 ", 19); /* Volume label, FAT signature */
+ }
ST_WORD(tbl + BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */
if (disk_write(pdrv, tbl, b_vol, 1) != RES_OK) /* Write it to the VBR sector */
return FR_DISK_ERR;
Author: ion
Date: Fri Jan 8 06:03:55 2016
New Revision: 70543
URL: http://svn.reactos.org/svn/reactos?rev=70543&view=rev
Log:
[BOOTMGFW]: Implement additional startup logic
[BOOTLIB]: Implement initial SecureBoot support.
[BOOTLIB]: Implement UEFI Variable query support.
Added:
trunk/reactos/boot/environ/include/efi/GlobalVariable.h (with props)
Modified:
trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
trunk/reactos/boot/environ/include/bl.h
trunk/reactos/boot/environ/lib/firmware/efi/firmware.c
trunk/reactos/boot/environ/lib/misc/util.c
Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Fri Jan 8 06:03:55 2016
@@ -1042,6 +1042,16 @@
}
NTSTATUS
+BlXmiWrite (
+ _In_ PWCHAR XmlTag
+ )
+{
+ /* Sigh */
+ EfiPrintf(L"XML: %s\r\n", XmlTag);
+ return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
BlXmiInitialize (
_In_ PWCHAR Stylesheet
)
@@ -1082,15 +1092,75 @@
VOID
)
{
- EfiPrintf(L"Device Type %d Local Type %d\r\n", BlpBootDevice->DeviceType, BlpBootDevice->Local.Type);
+ /* Check if we're booted by UEFI off the DVD directlry */
if ((BlpBootDevice->DeviceType == LocalDevice) &&
(BlpBootDevice->Local.Type == CdRomDevice) &&
(BlpApplicationFlags & BL_APPLICATION_FLAG_CONVERTED_FROM_EFI))
{
+ /* Windows actually bypasses integrity checks in this case. Works for us */
return STATUS_SUCCESS;
}
+ /* Our binaries aren't signed, so always return failure */
return 0xC0000428;
+}
+
+NTSTATUS
+BmFwRegisterRevocationList (
+ VOID
+ )
+{
+ NTSTATUS Status;
+ BOOLEAN SecureBootEnabled;
+
+ /* Is SecureBoot enabled? */
+ Status = BlSecureBootIsEnabled(&SecureBootEnabled);
+ if ((NT_SUCCESS(Status)) && (SecureBootEnabled))
+ {
+ EfiPrintf(L"SB not implemented revok\r\n");
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ else
+ {
+ /* Nothing to do without SecureBoot */
+ Status = STATUS_SUCCESS;
+ }
+
+ /* Return revocation result back to caller */
+ return Status;
+}
+
+NTSTATUS
+BmResumeFromHibernate (
+ _Out_ PHANDLE BcdResumeHandle
+ )
+{
+ NTSTATUS Status;
+ BOOLEAN AttemptResume;
+
+ /* Should we attempt to resume from hibernation? */
+ Status = BlGetBootOptionBoolean(BlpApplicationEntry.BcdData,
+ BcdBootMgrBoolean_AttemptResume,
+ &AttemptResume);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Nope. Is automatic restart on crash enabled? */
+ AttemptResume = FALSE;
+ Status = BlGetBootOptionBoolean(BlpApplicationEntry.BcdData,
+ BcdOSLoaderBoolean_DisableCrashAutoReboot,
+ &AttemptResume);
+ AttemptResume = (NT_SUCCESS(Status) && (AttemptResume));
+ }
+
+ /* Don't do anything if there's no need to resume anything */
+ if (!AttemptResume)
+ {
+ return STATUS_SUCCESS;
+ }
+
+ /* Not yet implemented */
+ EfiPrintf(L"Resume not supported\r\n");
+ return STATUS_NOT_IMPLEMENTED;
}
/*++
@@ -1116,7 +1186,7 @@
PBL_RETURN_ARGUMENTS ReturnArguments;
BOOLEAN RebootOnError;
PGUID AppIdentifier;
- HANDLE BcdHandle;
+ HANDLE BcdHandle, ResumeBcdHandle;
PBL_BCD_OPTION EarlyOptions;
PWCHAR Stylesheet;
BOOLEAN XmlLoaded, DisableIntegrity, TestSigning;
@@ -1267,14 +1337,36 @@
}
}
-// BlXmiWrite(L"<bootmgr/>");
-
- //BlSecureBootCheckForFactoryReset();
+ /* Write out the first XML tag */
+ BlXmiWrite(L"<bootmgr/>");
+
+ /* Check for factory resset */
+ BlSecureBootCheckForFactoryReset();
+
+ /* Load the revocation list */
+ Status = BmFwRegisterRevocationList();
+ if (!NT_SUCCESS(Status))
+ {
+ goto Failure;
+ }
+
+ /* Register our custom progress routine */
+ BlUtlRegisterProgressRoutine();
+
+ /* Display state is not currently cached */
+ BmDisplayStateCached = FALSE;
+
+ /* Check if w need to resume from hibernate */
+ Status = BmResumeFromHibernate(&ResumeBcdHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ goto Failure;
+ }
/* do more stuff!! */
- EfiPrintf(BlResourceFindMessage(BM_MSG_TEST));
- EfiPrintf(Stylesheet);
+ //EfiPrintf(BlResourceFindMessage(BM_MSG_TEST));
+ //EfiPrintf(Stylesheet);
EfiStall(10000000);
Failure:
Modified: trunk/reactos/boot/environ/include/bl.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?…
==============================================================================
--- trunk/reactos/boot/environ/include/bl.h [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/include/bl.h [iso-8859-1] Fri Jan 8 06:03:55 2016
@@ -39,6 +39,7 @@
#include <UgaDraw.h>
#include <BlockIo.h>
#include <Acpi.h>
+#include <GlobalVariable.h>
/* Registry Headers */
#define __FREELDR_H
@@ -1528,6 +1529,11 @@
VOID
);
+NTSTATUS
+BlUtlRegisterProgressRoutine (
+ VOID
+ );
+
VOID
BlFwReboot (
VOID
@@ -1535,6 +1541,21 @@
PGUID
BlGetApplicationIdentifier (
+ VOID
+ );
+
+NTSTATUS
+BlpSecureBootEFIIsEnabled (
+ VOID
+ );
+
+NTSTATUS
+BlSecureBootIsEnabled (
+ _Out_ PBOOLEAN SecureBootEnabled
+ );
+
+NTSTATUS
+BlSecureBootCheckForFactoryReset (
VOID
);
@@ -2302,6 +2323,7 @@
extern EFI_GUID EfiSimpleTextInputExProtocol;
extern EFI_GUID EfiRootAcpiTableGuid;
extern EFI_GUID EfiRootAcpiTable10Guid;
+extern EFI_GUID EfiGlobalVariable;
extern ULONG ConsoleGraphicalResolutionListFlags;
extern BL_DISPLAY_MODE ConsoleGraphicalResolutionList[];
extern BL_DISPLAY_MODE ConsoleTextResolutionList[];
Added: trunk/reactos/boot/environ/include/efi/GlobalVariable.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/efi/G…
==============================================================================
--- trunk/reactos/boot/environ/include/efi/GlobalVariable.h (added)
+++ trunk/reactos/boot/environ/include/efi/GlobalVariable.h [iso-8859-1] Fri Jan 8 06:03:55 2016
@@ -0,0 +1,192 @@
+/** @file
+ GUID for EFI (NVRAM) Variables.
+
+ Copyright (c) 2006 - 2015, 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.1
+**/
+
+#ifndef __GLOBAL_VARIABLE_GUID_H__
+#define __GLOBAL_VARIABLE_GUID_H__
+
+#define EFI_GLOBAL_VARIABLE \
+ { \
+ 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C } \
+ }
+
+extern EFI_GUID gEfiGlobalVariableGuid;
+
+//
+// Follow UEFI 2.4 spec:
+// To prevent name collisions with possible future globally defined variables,
+// other internal firmware data variables that are not defined here must be
+// saved with a unique VendorGuid other than EFI_GLOBAL_VARIABLE or
+// any other GUID defined by the UEFI Specification. Implementations must
+// only permit the creation of variables with a UEFI Specification-defined
+// VendorGuid when these variables are documented in the UEFI Specification.
+//
+// Note: except the globally defined variables defined below, the spec also defines
+// L"Boot####" - A boot load option.
+// L"Driver####" - A driver load option.
+// L"SysPrep####" - A System Prep application load option.
+// L"Key####" - Describes hot key relationship with a Boot#### load option.
+// The attribute for them is NV+BS+RT, #### is a printed hex value, and no 0x or h
+// is included in the hex value. They can not be expressed as a #define like other globally
+// defined variables, it is because we can not list the Boot0000, Boot0001, etc one by one.
+//
+
+///
+/// The language codes that the firmware supports. This value is deprecated.
+/// Its attribute is BS+RT.
+///
+#define EFI_LANG_CODES_VARIABLE_NAME L"LangCodes"
+///
+/// The language code that the system is configured for. This value is deprecated.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_LANG_VARIABLE_NAME L"Lang"
+///
+/// The firmware's boot managers timeout, in seconds, before initiating the default boot selection.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_TIME_OUT_VARIABLE_NAME L"Timeout"
+///
+/// The language codes that the firmware supports.
+/// Its attribute is BS+RT.
+///
+#define EFI_PLATFORM_LANG_CODES_VARIABLE_NAME L"PlatformLangCodes"
+///
+/// The language code that the system is configured for.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_PLATFORM_LANG_VARIABLE_NAME L"PlatformLang"
+///
+/// The device path of the default input/output/error output console.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_CON_IN_VARIABLE_NAME L"ConIn"
+#define EFI_CON_OUT_VARIABLE_NAME L"ConOut"
+#define EFI_ERR_OUT_VARIABLE_NAME L"ErrOut"
+///
+/// The device path of all possible input/output/error output devices.
+/// Its attribute is BS+RT.
+///
+#define EFI_CON_IN_DEV_VARIABLE_NAME L"ConInDev"
+#define EFI_CON_OUT_DEV_VARIABLE_NAME L"ConOutDev"
+#define EFI_ERR_OUT_DEV_VARIABLE_NAME L"ErrOutDev"
+///
+/// The ordered boot option load list.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_BOOT_ORDER_VARIABLE_NAME L"BootOrder"
+///
+/// The boot option for the next boot only.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_BOOT_NEXT_VARIABLE_NAME L"BootNext"
+///
+/// The boot option that was selected for the current boot.
+/// Its attribute is BS+RT.
+///
+#define EFI_BOOT_CURRENT_VARIABLE_NAME L"BootCurrent"
+///
+/// The types of boot options supported by the boot manager. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_BOOT_OPTION_SUPPORT_VARIABLE_NAME L"BootOptionSupport"
+///
+/// The ordered driver load option list.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_DRIVER_ORDER_VARIABLE_NAME L"DriverOrder"
+///
+/// The ordered System Prep Application load option list.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_SYS_PREP_ORDER_VARIABLE_NAME L"SysPrepOrder"
+///
+/// Identifies the level of hardware error record persistence
+/// support implemented by the platform. This variable is
+/// only modified by firmware and is read-only to the OS.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_HW_ERR_REC_SUPPORT_VARIABLE_NAME L"HwErrRecSupport"
+///
+/// Whether the system is operating in setup mode (1) or not (0).
+/// All other values are reserved. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_SETUP_MODE_NAME L"SetupMode"
+///
+/// The Key Exchange Key Signature Database.
+/// Its attribute is NV+BS+RT+AT.
+///
+#define EFI_KEY_EXCHANGE_KEY_NAME L"KEK"
+///
+/// The public Platform Key.
+/// Its attribute is NV+BS+RT+AT.
+///
+#define EFI_PLATFORM_KEY_NAME L"PK"
+///
+/// Array of GUIDs representing the type of signatures supported
+/// by the platform firmware. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_SIGNATURE_SUPPORT_NAME L"SignatureSupport"
+///
+/// Whether the platform firmware is operating in Secure boot mode (1) or not (0).
+/// All other values are reserved. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_SECURE_BOOT_MODE_NAME L"SecureBoot"
+///
+/// The OEM's default Key Exchange Key Signature Database. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_KEK_DEFAULT_VARIABLE_NAME L"KEKDefault"
+///
+/// The OEM's default public Platform Key. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_PK_DEFAULT_VARIABLE_NAME L"PKDefault"
+///
+/// The OEM's default secure boot signature store. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_DB_DEFAULT_VARIABLE_NAME L"dbDefault"
+///
+/// The OEM's default secure boot blacklist signature store. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_DBX_DEFAULT_VARIABLE_NAME L"dbxDefault"
+///
+/// The OEM's default secure boot timestamp signature store. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_DBT_DEFAULT_VARIABLE_NAME L"dbtDefault"
+///
+/// Allows the firmware to indicate supported features and actions to the OS.
+/// Its attribute is BS+RT.
+///
+#define EFI_OS_INDICATIONS_SUPPORT_VARIABLE_NAME L"OsIndicationsSupported"
+///
+/// Allows the OS to request the firmware to enable certain features and to take certain actions.
+/// Its attribute is NV+BS+RT.
+///
+#define EFI_OS_INDICATIONS_VARIABLE_NAME L"OsIndications"
+///
+/// Whether the system is configured to use only vendor provided
+/// keys or not. Should be treated as read-only.
+/// Its attribute is BS+RT.
+///
+#define EFI_VENDOR_KEYS_VARIABLE_NAME L"VendorKeys"
+
+#endif
Propchange: trunk/reactos/boot/environ/include/efi/GlobalVariable.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/firmware/…
==============================================================================
--- trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] Fri Jan 8 06:03:55 2016
@@ -33,8 +33,13 @@
EFI_GUID EfiBlockIoProtocol = EFI_BLOCK_IO_PROTOCOL_GUID;
EFI_GUID EfiRootAcpiTableGuid = EFI_ACPI_20_TABLE_GUID;
EFI_GUID EfiRootAcpiTable10Guid = EFI_ACPI_TABLE_GUID;
+EFI_GUID EfiGlobalVariable = EFI_GLOBAL_VARIABLE;
+EFI_GUID BlpEfiSecureBootPrivateNamespace = { 0x77FA9ABD , 0x0359, 0x4D32, { 0xBD, 0x60, 0x28, 0xF4, 0xE7, 0x8F, 0x78, 0x4B } };
WCHAR BlScratchBuffer[8192];
+
+BOOLEAN BlpFirmwareChecked;
+BOOLEAN BlpFirmwareEnabled;
/* FUNCTIONS *****************************************************************/
@@ -265,6 +270,159 @@
}
/* All done */
+ return Status;
+}
+
+NTSTATUS
+EfiGetVariable (
+ _In_ PWCHAR VariableName,
+ _In_ EFI_GUID* VendorGuid,
+ _Out_opt_ PULONG Attributes,
+ _Inout_ PULONG DataSize,
+ _Out_ PVOID Data
+ )
+{
+ EFI_STATUS EfiStatus;
+ NTSTATUS Status;
+ BL_ARCH_MODE OldMode;
+ ULONG LocalAttributes;
+
+ /* Are we in protected mode? */
+ OldMode = CurrentExecutionContext->Mode;
+ if (OldMode != BlRealMode)
+ {
+ /* FIXME: Not yet implemented */
+ return STATUS_NOT_IMPLEMENTED;
+ }
+
+ /* Call the runtime API */
+ EfiStatus = EfiRT->GetVariable(VariableName,
+ VendorGuid,
+ (UINT32*)&LocalAttributes,
+ (UINTN*)DataSize,
+ Data);
+
+ /* Switch back to protected mode if we came from there */
+ if (OldMode != BlRealMode)
+ {
+ BlpArchSwitchContext(OldMode);
+ }
+
+ /* Return attributes back to the caller if asked to */
+ if (Attributes)
+ {
+ *Attributes = LocalAttributes;
+ }
+
+ /* Convert the errot to an NTSTATUS and return it */
+ Status = EfiGetNtStatusCode(EfiStatus);
+ return Status;
+}
+
+NTSTATUS
+BlpSecureBootEFIIsEnabled (
+ VOID
+ )
+{
+ NTSTATUS Status;
+ BOOLEAN SetupMode, SecureBoot;
+ ULONG DataSize;
+
+ /* Assume setup mode enabled, and no secure boot */
+ SecureBoot = FALSE;
+ SetupMode = TRUE;
+
+ /* Get the SetupMode variable */
+ DataSize = sizeof(SetupMode);
+ Status = EfiGetVariable(L"SetupMode",
+ &EfiGlobalVariable,
+ NULL,
+ &DataSize,
+ &SetupMode);
+ if (NT_SUCCESS(Status))
+ {
+ /* If it worked, get the SecureBoot variable */
+ DataSize = sizeof(SecureBoot);
+ Status = EfiGetVariable(L"SecureBoot",
+ &EfiGlobalVariable,
+ NULL,
+ &DataSize,
+ &SecureBoot);
+ if (NT_SUCCESS(Status))
+ {
+ /* In setup mode or without secureboot turned on, return failure */
+ if ((SecureBoot != TRUE) || (SetupMode))
+ {
+ Status = STATUS_INVALID_SIGNATURE;
+ }
+
+ // BlpSbdiStateFlags |= 8u;
+ }
+ }
+
+ /* Return secureboot status */
+ return Status;
+}
+
+NTSTATUS
+BlSecureBootIsEnabled (
+ _Out_ PBOOLEAN SecureBootEnabled
+ )
+{
+ NTSTATUS Status;
+
+ /* Have we checked before ? */
+ if (!BlpFirmwareChecked)
+ {
+ /* First time checking */
+ Status = BlpSecureBootEFIIsEnabled();
+ if NT_SUCCESS(Status)
+ {
+ /* Yep, it's on */
+ BlpFirmwareEnabled = TRUE;
+ }
+
+ /* Don't check again */
+ BlpFirmwareChecked = TRUE;
+ }
+
+ /* Return the firmware result */
+ *SecureBootEnabled = BlpFirmwareEnabled;
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+BlSecureBootCheckForFactoryReset (
+ VOID
+ )
+{
+ BOOLEAN SecureBootEnabled;
+ NTSTATUS Status;
+ ULONG DataSize;
+
+ /* Initialize locals */
+ DataSize = 0;
+ SecureBootEnabled = FALSE;
+
+ /* Check if secureboot is enabled */
+ Status = BlSecureBootIsEnabled(&SecureBootEnabled);
+ if (!(NT_SUCCESS(Status)) || !(SecureBootEnabled))
+ {
+ /* It's not. Check if there's a revocation list */
+ Status = EfiGetVariable(L"RevocationList",
+ &BlpEfiSecureBootPrivateNamespace,
+ NULL,
+ &DataSize,
+ NULL);
+ if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_TOO_SMALL))
+ {
+ /* We don't support this yet */
+ EfiPrintf(L"Not yet supported\r\n");
+ Status = STATUS_NOT_IMPLEMENTED;
+ }
+ }
+
+ /* Return back to the caller */
return Status;
}
Modified: trunk/reactos/boot/environ/lib/misc/util.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/util…
==============================================================================
--- trunk/reactos/boot/environ/lib/misc/util.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/misc/util.c [iso-8859-1] Fri Jan 8 06:03:55 2016
@@ -27,6 +27,8 @@
ULONG UtlNextUpdatePercentage;
BOOLEAN UtlProgressNeedsInfoUpdate;
PVOID UtlProgressInfo;
+
+
/* FUNCTIONS *****************************************************************/
@@ -176,6 +178,7 @@
return STATUS_NOT_FOUND;
}
+
VOID
BlUtlUpdateProgress (
_In_ ULONG Percentage,
@@ -213,6 +216,58 @@
UtlProgressNeedsInfoUpdate = 0;
UtlProgressInfo = 0;
+ return STATUS_SUCCESS;
+}
+
+VOID
+BmUpdateProgressInfo (
+ _In_ PVOID Uknown,
+ _In_ PWCHAR ProgressInfo
+ )
+{
+ EfiPrintf(L"Progress Info: %s\r\n", ProgressInfo);
+}
+
+VOID
+BmUpdateProgress (
+ _In_ PVOID Unknown,
+ _In_ ULONG Percent,
+ _Out_ PBOOLEAN Completed
+ )
+{
+ EfiPrintf(L"Progress: %d\r\n", Percent);
+ if (Completed)
+ {
+ *Completed = TRUE;
+ }
+}
+
+NTSTATUS
+BlUtlRegisterProgressRoutine (
+ VOID
+ )
+{
+ /* One shouldn't already exist */
+ if (UtlProgressRoutine)
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Set the routine, and no context */
+ UtlProgressRoutine = BmUpdateProgress;
+ UtlProgressContext = NULL;
+
+ /* Progress increases by one */
+ UtlProgressGranularity = 1;
+
+ /* Set progress to zero for now */
+ UtlCurrentPercentComplete = 0;
+ UtlNextUpdatePercentage = 0;
+
+ /* Set the info routine if there is one */
+ UtlProgressInfoRoutine = BmUpdateProgressInfo;
+
+ /* All good */
return STATUS_SUCCESS;
}
Author: ion
Date: Fri Jan 8 01:18:08 2016
New Revision: 70542
URL: http://svn.reactos.org/svn/reactos?rev=70542&view=rev
Log:
Three tiny squirmy subtle bugs combined themselves with the bug that was just fixed to make bootmgfw believe it was being booted from a raw removable disk (floppy). Because bootmgfw now correctly enumerates boot devices and detects the DVD/CDROM media, it could no longer 'find itself', believing it was on a floppy.
[BOOTLIB]: When failing to find a block device, keep going searching for more, instead of giving up (critical, because the CDROM FAT12 image is now device path #1, not #0).
[BOOTMGR]: Correctly use the right logical operator in EfiInitpGetDeviceNode to get the deepest-level media device node. We now get the CDROM node, not the raw node.
[CDMAKE]: Don't actually create an EFI/BOOT directory on the CDROM itself, but rather in the FAT12 image. Otherwise, this can confuse UEFI implementations to boot the boot manager off the raw CDROM, instead of the FAT12 image on the CDROM.
Modified:
trunk/reactos/boot/environ/CMakeLists.txt
trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
trunk/reactos/boot/environ/app/bootmgr/efiemu.c
trunk/reactos/boot/environ/lib/io/device.c
Modified: trunk/reactos/boot/environ/CMakeLists.txt
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/CMakeLists.tx…
==============================================================================
--- trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/CMakeLists.txt [iso-8859-1] Fri Jan 8 01:18:08 2016
@@ -105,5 +105,3 @@
add_dependencies(bootmgfw asm bugcodes)
-add_cd_file(TARGET bootmgfw FILE ${_bootmgfw_output_file} DESTINATION efi/boot NO_CAB FOR bootcd regtest NAME_ON_CD boot${EFI_PLATFORM_ID}.efi)
-
Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Fri Jan 8 01:18:08 2016
@@ -1263,7 +1263,7 @@
if (!NT_SUCCESS(Status))
{
/* Signature invalid, fail boot */
- // goto Failure;
+ goto Failure;
}
}
Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/e…
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/efiemu.c [iso-8859-1] Fri Jan 8 01:18:08 2016
@@ -319,7 +319,7 @@
/* Loop each device path, until we get to the end or to a file path device node */
for ((NextPath = NextDevicePathNode(DevicePath));
- !(IsDevicePathEndType(NextPath)) && ((NextPath->Type != MEDIA_DEVICE_PATH) &&
+ !(IsDevicePathEndType(NextPath)) && ((NextPath->Type != MEDIA_DEVICE_PATH) ||
(NextPath->SubType != MEDIA_FILEPATH_DP));
(NextPath = NextDevicePathNode(NextPath)))
{
Modified: trunk/reactos/boot/environ/lib/io/device.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/io/device…
==============================================================================
--- trunk/reactos/boot/environ/lib/io/device.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/io/device.c [iso-8859-1] Fri Jan 8 01:18:08 2016
@@ -1276,7 +1276,7 @@
if (!NT_SUCCESS(Status))
{
EfiPrintf(L"EFI create failed: %lx\n", Status);
- break;
+ continue;
}
/* Add the device entry to the device table */
Author: ion
Date: Fri Jan 8 00:15:00 2016
New Revision: 70540
URL: http://svn.reactos.org/svn/reactos?rev=70540&view=rev
Log:
[BOOTLIB]: Fix a few subtle bugs which made us incorrectly believe that we were booting from a raw removable drive. We now correctly detect that we are booting off CDROM media. Of course, now everything else is hopelessly broken and we've regressed to die before we get anywhere. Progress.
Modified:
trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
trunk/reactos/boot/environ/lib/firmware/efi/firmware.c
trunk/reactos/boot/environ/lib/io/device.c
Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/b…
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c [iso-8859-1] Fri Jan 8 00:15:00 2016
@@ -1085,7 +1085,7 @@
EfiPrintf(L"Device Type %d Local Type %d\r\n", BlpBootDevice->DeviceType, BlpBootDevice->Local.Type);
if ((BlpBootDevice->DeviceType == LocalDevice) &&
(BlpBootDevice->Local.Type == CdRomDevice) &&
- (BlpApplicationFlags & BL_APPLICATION_ENTRY_FLAG_NO_GUID))
+ (BlpApplicationFlags & BL_APPLICATION_FLAG_CONVERTED_FROM_EFI))
{
return STATUS_SUCCESS;
}
Modified: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/firmware/…
==============================================================================
--- trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/firmware/efi/firmware.c [iso-8859-1] Fri Jan 8 00:15:00 2016
@@ -44,14 +44,21 @@
_In_ EFI_DEVICE_PATH *DevicePath2
)
{
+ EFI_DEVICE_PATH* CurrentPath1;
+ EFI_DEVICE_PATH* CurrentPath2;
USHORT Length1, Length2;
+ /* Start with the current nodes */
+ CurrentPath1 = DevicePath1;
+ CurrentPath2 = DevicePath2;
+
/* Loop each element of the device path */
- while (!IsDevicePathEndType(DevicePath1) && !IsDevicePathEndType(DevicePath2))
+ while (!(IsDevicePathEndType(CurrentPath1)) &&
+ !(IsDevicePathEndType(CurrentPath2)))
{
/* Check if the element has a different length */
- Length1 = DevicePathNodeLength(DevicePath1);
- Length2 = DevicePathNodeLength(DevicePath2);
+ Length1 = DevicePathNodeLength(CurrentPath1);
+ Length2 = DevicePathNodeLength(CurrentPath2);
if (Length1 != Length2)
{
/* Then they're not related */
@@ -59,25 +66,25 @@
}
/* Check if the rest of the element data matches */
- if (RtlCompareMemory(DevicePath1, DevicePath2, Length1) != Length1)
+ if (RtlCompareMemory(CurrentPath1, CurrentPath2, Length1) != Length1)
{
/* Nope, not related */
return NULL;
}
/* Move to the next element */
- DevicePath1 = NextDevicePathNode(DevicePath1);
- DevicePath2 = NextDevicePathNode(DevicePath2);
+ CurrentPath1 = NextDevicePathNode(CurrentPath1);
+ CurrentPath2 = NextDevicePathNode(CurrentPath2);
}
/* If the last element in path 1 is empty, then path 2 is the child (deeper) */
- if (!IsDevicePathEndType(DevicePath1))
+ if (!IsDevicePathEndType(CurrentPath1))
{
return DevicePath2;
}
/* If the last element in path 2 is empty, then path 1 is the child (deeper) */
- if (!IsDevicePathEndType(DevicePath2))
+ if (!IsDevicePathEndType(CurrentPath2))
{
return DevicePath1;
}
Modified: trunk/reactos/boot/environ/lib/io/device.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/io/device…
==============================================================================
--- trunk/reactos/boot/environ/lib/io/device.c [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/io/device.c [iso-8859-1] Fri Jan 8 00:15:00 2016
@@ -920,7 +920,8 @@
/* Yup, return back to caller */
ChildProtocolInterface->Handle = Handle;
ChildProtocolInterface->Interface = DevicePath;
- break;
+ Status = STATUS_SUCCESS;
+ goto Quickie;
}
/* Close the device path */
@@ -930,6 +931,7 @@
/* If we got here, nothing was found */
Status = STATUS_NO_SUCH_DEVICE;
+Quickie:
/* Free the handle array buffer */
BlMmFreeHeap(DeviceHandles);
return Status;
@@ -981,6 +983,7 @@
/* Iteratate twice -- once for the top level, once for the bottom */
for (i = 0, Found = FALSE; Found == FALSE && Protocol[i].Handle; i++)
{
+ /* Check what kind of leaf node device this is */
LeafNode = EfiGetLeafNode(Protocol[i].Interface);
EfiPrintf(L"Pass %d, Leaf node: %p Type: %d\r\n", i, LeafNode, LeafNode->Type);
if (LeafNode->Type == ACPI_DEVICE_PATH)