/** @file
Copyright (c) 2006 - 2011, 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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Abstract:
NOTE:
If we write MBR to disk, we just update the MBR code and the partition table wouldn't be over written.
If we process DBR, we will patch MBR to set first partition active if no active partition exists.
**/
#include "CommonLib.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <Common/UefiBaseTypes.h>
#include "ParseInf.h"
#include "EfiUtilityMsgs.h"
//
// Utility Name
//
//
// Utility version information
//
#define UTILITY_MAJOR_VERSION 0
#define DRIVE_UNKNOWN 0
typedef struct _DRIVE_TYPE_DESC {
#define DRIVE_TYPE_ITEM(x) {x, #x}
};
typedef struct _DRIVE_INFO {
} DRIVE_INFO;
typedef enum {
} PATH_TYPE;
typedef struct _PATH_INFO {
} PATH_INFO;
typedef enum {
} ERROR_STATUS;
"Success",
"Failed to create files",
"No MBR exists",
"Failed to detect Fat type",
"Inavlid path"
};
//UnSupported Windows API functions.
/**
Get path information, including physical path for Linux platform.
@param PathInfo Point to PATH_INFO structure.
@return whether path is valid.
**/
)
{
FILE *f;
//
// Process disk path here.
//
// Process floppy disk
return ErrorSuccess;
} else {
// Other disk types is not supported yet.
return ErrorPath;
}
// Try to open the device.
if (f == NULL) {
printf ("error :open device failed!\n");
return ErrorPath;
}
fclose (f);
return ErrorSuccess;
}
// Process file path here.
// If path is file path, check whether file is valid.
if (f == NULL) {
return ErrorPath;
}
fclose (f);
}
return ErrorSuccess;
}
)
{
printf("-l or -list not supported!\n");
}
/**
Writing or reading boot sector or MBR according to the argument.
@param InputInfo PATH_INFO instance for input path
@param OutputInfo PATH_INFO instance for output path
@param ProcessMbr TRUE is to process MBR, otherwise, processing boot sector
@return ERROR_STATUS
**/
)
{
return ErrorFileReadWrite;
}
return ErrorFileReadWrite;
}
//Not support USB and IDE.
printf("USB has not been supported yet!");
return ErrorSuccess;
}
printf("IDE has not been supported yet!");
return ErrorSuccess;
}
//Process Floppy Disk
if (OutputFile == NULL) {
if (OutputFile == NULL) {
return ErrorFileReadWrite;
}
}
if (ProcessMbr) {
//
// Use original partition table
//
return ErrorFileReadWrite;
}
}
}
return ErrorFileReadWrite;
}
return ErrorSuccess;
}
/**
Displays the standard utility information to SDTOUT
**/
Version (
)
{
printf ("%s v%d.%d %s-Utility to retrieve and update the boot sector or MBR.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
printf ("Copyright (c) 2007-2010 Intel Corporation. All rights reserved.\n");
}
)
{
Version();
printf ("\nUsage: \n\
GenBootSector\n\
[-l, --list list disks]\n\
[-i, --input Filename]\n\
[-o, --output Filename]\n\
[-m, --mbr process the MBR also]\n\
[-v, --verbose]\n\
[--version]\n\
[-q, --quiet disable all messages except fatal errors]\n\
[-d, --debug[#]\n\
[-h, --help]\n");
}
int
main (
int argc,
char *argv[]
)
{
argv ++;
argc --;
ProcessMbr = FALSE;
if (argc == 0) {
PrintUsage();
return 0;
}
//
// Parse command line
//
ListDrive ();
return 0;
}
ProcessMbr = TRUE;
continue;
}
return 1;
}
return 1;
}
++Index;
continue;
}
return 1;
}
return 1;
}
++Index;
continue;
}
PrintUsage ();
return 0;
}
Version ();
return 0;
}
continue;
}
continue;
}
return 1;
}
if (LogLevel > 9) {
Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) LogLevel);
return 1;
}
++Index;
continue;
}
//
// Don't recognize the parameter.
//
return 1;
}
return 1;
}
return 1;
}
return 1;
}
return 1;
}
//
// Process DBR (Patch or Read)
//
if (Status == ErrorSuccess) {
fprintf (
"%s %s: successful!\n",
);
return 0;
} else {
fprintf (
"%s: %s %s: failed - %s (LastError: 0x%x)!\n",
);
return 1;
}
}