📄 write_boot.c
字号:
/*
* +-------------------------------------------------------------------+
* | Copyright (c) 1995,2000 TriMedia Technologies Inc. |
* | |
* | This software is furnished under a license and may only be used |
* | and copied in accordance with the terms and conditions of such a |
* | license and with the inclusion of this copyright notice. This |
* | software or any other copies of this software may not be provided |
* | or otherwise made available to any other person. The ownership |
* | and title of this software is not transferred. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | TriMedia Technologies. |
* | |
* | This code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +-------------------------------------------------------------------+
*/
#include <tmlib/tmtypes.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include "tmlib/tmFlash.h"
/*------------------------------ Event handler ------------------------------*/
static void event_handler(FlashEvent event);
static EventHandler old_event_handler= event_handler;
static void event_handler(FlashEvent event)
{
switch (event) {
case FlashFull:
old_event_handler(event);
exit(-1);
case FlashWriteError:
case FlashStaleSTTRemoved:
case FlashStaleRootRemoved:
case FlashStaleBootRemoved:
case FlashDangerousWriteError:
case FlashInterruptedMoveRepaired:
old_event_handler(event);
break;
}
}
/*------------------------------ Main program --------------------------------*/
static void write_sectormap()
{
printf("--------------------------------------------------\n");
FlashUtil_print();
printf("--------------------------------------------------\n");
}
void main( Int argc, String argv[])
{
old_event_handler= Flash_install_event_handler( event_handler );
atexit(write_sectormap);
if (argc ==1) {
exit(-1);
} else {
FILE *f;
f= fopen(argv[1], "rb");
if (f == Null) {
exit(-2);
} else {
Pointer result;
struct stat buf;
stat(argv[1], &buf);
result = (Pointer)malloc(buf.st_size);
if (result == Null) {
exit(-3);
} else {
fread(result,1,buf.st_size,f);
fclose(f);
if (!FlashUtil_put_bootimage(result,(Pointer)BOOT_ADDRESS,buf.st_size)) {
exit(-4);
} else {
exit(0);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -