📄 bioscall.c
字号:
#include "types.h"#include "bioscall.h"#include "config.h"int bios_call(unsigned long id, unsigned long arg){ BIOSCALL *bios_call_ptr = (BIOSCALL *)BIOS_API_ADDR; return bios_call_ptr(id, arg);}int bios_reboot(){ return bios_call(BIOSCALL_REBOOT, 0);}unsigned short bios_vendor_id(void){ unsigned short vendor_id; bios_call(BIOSCALL_GET_VENDORID, (unsigned long)&vendor_id); return vendor_id;}unsigned short bios_device_id(void){ unsigned short device_id; bios_call(BIOSCALL_GET_DEVICEID, (unsigned long)&device_id); return device_id;}unsigned long bios_rev(void){ unsigned long rev; bios_call(BIOSCALL_GET_REV, (unsigned long)&rev); return rev;}unsigned long bios_system_table_offset(void){ unsigned long system_table_offset; bios_call(BIOSCALL_GET_SYSTEMTABLEOFFSET, (unsigned long)&system_table_offset); return system_table_offset;}unsigned long bios_system_table_size(void){ unsigned long system_table_size; bios_call(BIOSCALL_GET_SYSTEMTABLESIZE, (unsigned long)&system_table_size); return system_table_size;}unsigned long bios_partition_table_offset(void){ unsigned long partition_table_offset; bios_call(BIOSCALL_GET_PARTITIONTABLEOFFSET, (unsigned long)&partition_table_offset); return partition_table_offset;}unsigned long bios_partition_table_size(void){ unsigned long partition_table_size; bios_call(BIOSCALL_GET_PARTITIONTABLESIZE, (unsigned long)&partition_table_size); return partition_table_size;}unsigned long bios_default_table_offset(void){ unsigned long default_table_offset; bios_call(BIOSCALL_GET_DEFAULTTABLEOFFSET, (unsigned long)&default_table_offset); return default_table_offset;}unsigned long bios_bios_offset(void){ unsigned long bios_offset; bios_call(BIOSCALL_GET_BIOSOFFSET, (unsigned long)&bios_offset); return bios_offset;}unsigned long bios_bios_size(void){ unsigned long bios_size; bios_call(BIOSCALL_GET_BIOSSIZE, (unsigned long)&bios_size); return bios_size;}unsigned long bios_rom_base(void){ unsigned long rom_base; bios_call(BIOSCALL_GET_ROMBASE, (unsigned long)&rom_base); return rom_base;}unsigned long bios_rom_size(void){ unsigned long rom_size; bios_call(BIOSCALL_GET_ROMSIZE, (unsigned long)&rom_size); return rom_size;}unsigned long bios_dram_base(void){ unsigned long dram_base; bios_call(BIOSCALL_GET_DRAMBASE, (unsigned long)&dram_base); return dram_base;}unsigned long bios_dram_size(void){ unsigned long dram_size; bios_call(BIOSCALL_GET_DRAMSIZE, (unsigned long)&dram_size); return dram_size;}unsigned long bios_startup_mode(void){ unsigned long startup_mode; bios_call(BIOSCALL_GET_STARTUPMODE, (unsigned long)&startup_mode); return startup_mode;}unsigned long bios_get_userflag(void){ unsigned long userflag; bios_call(BIOSCALL_GET_USERFLAG, (unsigned long)&userflag); return userflag;}unsigned long bios_set_userflag(unsigned long userflag){ return bios_call(BIOSCALL_SET_USERFLAG, userflag);}int bios_flash_erase(unsigned long adr, unsigned long size){ struct flash_erase_struct flash_erase; flash_erase.addr = adr; flash_erase.size = size; return bios_call(BIOSCALL_FLASH_ERASE, (unsigned long)&flash_erase);}int bios_flash_read(unsigned long from, unsigned long len, unsigned long *retlen, unsigned char *buf){ struct flash_read_struct flash_read; int ret; flash_read.from = from; flash_read.len = len; flash_read.buf = buf; ret = bios_call(BIOSCALL_FLASH_READ, (unsigned long)&flash_read); *retlen = flash_read.retlen; return ret;}int bios_flash_write(unsigned long to, unsigned long len, unsigned long *retlen, unsigned char *buf){ struct flash_write_struct flash_write; int ret; flash_write.to = to; flash_write.len = len; flash_write.buf = buf; ret = bios_call(BIOSCALL_FLASH_WRITE, (unsigned long)&flash_write); *retlen = flash_write.retlen; return ret;}int bios_system_table(struct system_table_struct *system_table){ unsigned long system_table_offset, system_table_size, l; system_table_offset = bios_system_table_offset(); system_table_size = bios_system_table_size(); return bios_flash_read(system_table_offset, system_table_size, &l, (unsigned char *)system_table);}int bios_default_table(struct system_table_struct *default_table){ unsigned long default_table_offset, system_table_size, l; default_table_offset = bios_default_table_offset(); system_table_size = bios_system_table_size(); return bios_flash_read(default_table_offset, system_table_size, &l, (unsigned char *)default_table);}int bios_partition_table(struct partition_table_struct *partition_table){ unsigned long partition_table_offset, partition_table_size, l; partition_table_offset = bios_partition_table_offset(); partition_table_size = bios_partition_table_size(); return bios_flash_read(partition_table_offset, partition_table_size, &l, (unsigned char *)partition_table);}int bios_eth_cfg(struct sys_eth_cfg *eth){ unsigned long offset, from, l; offset = bios_system_table_offset(); from = (unsigned long)&(((struct system_table_struct *)offset)->eth); return bios_flash_read(from, sizeof(struct sys_eth_cfg), &l, (unsigned char *)eth);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -