📄 bootconfig.c
字号:
/***************************************** Copyright (c) 2001-2004 Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************//* This file is part of the EM86XX boot loader *//* * bootconfig.c * * first revision by Ho Lee 10/30/2002 * configuration load & save 11/11/2002 * ported from Jasper boot loader 05/29/2003 */#include "config.h"#include "uart.h"#include "util.h"#include "net_ipv4.h"#include "bootconfig.h"//// configuration structure//// configuration is not saved always on the same area. because flash can't be overwritten// and it needs erasing before writing, it is not good idea to overwrite and burn flash // every time. so reserve some flash area for configuration, and write the new configuration// on the next available space, and mark which configuration is the last on the header//// header : (from = BOOTCONFIG_FLASHSTART, size = BOOTCONFIG_HEADSIZE)// signature (4 bytes) : BOOTCONFIG_HEADSIGN// bytes of bit-stream : bit 0 means 'configuration saved' // make use of the fact that : for the flash memory, only changing bit 1 to 0 is possible// 0xff : not saved// 0xfe : 1 saved// 0xfc : 2 saved// body : (from = BOOTCONFIG_FLASHSTART + BOOTCONFIG_HEADSIZE, size = BOOTCONFIG_SIZE)// bootconfig_t//#define BOOTCONFIG_FLASHSTART 0x1ff000#define BOOTCONFIG_FLASHEND 0x200000#define BOOTCONFIG_FLASHBUF 0x010000#define BOOTCONFIG_HEADSIZE 0x100#define BOOTCONFIG_SIZE 0x100#define BOOTCONFIG_MAXSAVE ((BOOTCONFIG_FLASHEND - BOOTCONFIG_FLASHSTART - BOOTCONFIG_HEADSIZE) / BOOTCONFIG_SIZE)#define BOOTCONFIG_POS(x) (BOOTCONFIG_FLASHSTART + BOOTCONFIG_HEADSIZE + (x) * BOOTCONFIG_SIZE)//// global variable//bootconfig_t g_bootconfig = { major_version : 1, minor_version : 0, checksum : BOOTCONFIG_BODYSIGN, kernel_cmdline : "", macaddr: { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, protocol : BOOTNET_DHCP, ipaddr : INADDR_FROM_4INTS(0,0,0,0), netmask : INADDR_FROM_4INTS(255,255,0,0), gateway : INADDR_FROM_4INTS(0,0,0,0), server : INADDR_FROM_4INTS(192,168,1,227), dns : 0x00000000, domain : "localdomain.com", loader_filename : DEFAULT_LOADER_FILENAME, misc_filename : DEFAULT_MISC_FILENAME, inst_filename : DEFAULT_INST_FILENAME, romfs_filename : DEFAULT_ROMFS_FILENAME, kernel_filename : DEFAULT_KERNEL_FILENAME, kernelfs_filename : DEFAULT_KERNELFS_FILENAME, initrd_filename : DEFAULT_INITRD_FILENAME,#ifdef CONFIG_ENABLE_2NDBOOT scnd_loader_filename : DEFAULT_2NDLOADER_FILENAME,#endif#ifdef CONFIG_ENABLE_IRQHANDLER irqhandler_filename : DEFAULT_IRQHANDLER_FILENAME,#endif#ifdef CONFIG_ENABLE_BITMAPS bitmap_filename : DEFAULT_IMAGE_FILENAME,#endif#ifdef CONFIG_ENABLE_UCODES ucode_filename : DEFAULT_UCODE_FILENAME,#endif#ifdef CONFIG_ENABLE_USERPREF userpref_filename : DEFAULT_USERPREF_FILENAME,#endif#ifdef CONFIG_ENABLE_VSYNCPARAM vsyncparam_filename : DEFAULT_VSYNCPARAM_FILENAME,#endif#ifdef CONFIG_ENABLE_DVI dvi_filename : DEFAULT_DVI_FILENAME,#endif};//// function prototypes//int bootconfig_load(int index);int bootconfig_save(void);int bootconfig_lastsaved(int *idx);//// Load & Save//// index : // 0 : last saved// > 0 : specified index-th saved configuration// return 0 on success, otherwise -1int bootconfig_load(int index){ return -1;}// return 0 on success, otherwise -1int bootconfig_save(void){ return -1;}// return the index of configuration last saved in idx parameter// return 0 on success, otherwise -1int bootconfig_lastsaved(int *idx){ return -1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -