📄 bioscall.c
字号:
#include "types.h"#include "bioscall.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 short bios_sub_vendor_id(void){ unsigned short sub_vendor_id; bios_call(BIOSCALL_GET_SUBVENDORID, (unsigned long)&sub_vendor_id); return sub_vendor_id;}unsigned short bios_sub_device_id(void){ unsigned short sub_device_id; bios_call(BIOSCALL_GET_SUBDEVICEID, (unsigned long)&sub_device_id); return sub_device_id;}unsigned long bios_rev(void){ unsigned long rev; bios_call(BIOSCALL_GET_REV, (unsigned long)&rev); return rev;}unsigned long bios_sys_clock(void){ unsigned long sys_clock; bios_call(BIOSCALL_GET_SYSCLOCK, (unsigned long)&sys_clock); return sys_clock;}unsigned long bios_ext_clock(void){ unsigned long ext_clock; bios_call(BIOSCALL_GET_EXTCLOCK, (unsigned long)&ext_clock); return ext_clock;}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_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_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_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;}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_uart0_cfg(struct uart_cfg *cfg){ return bios_call(BIOSCALL_GET_UART0CFG, (unsigned long)cfg);}int bios_uart1_cfg(struct uart_cfg *cfg){ return bios_call(BIOSCALL_GET_UART1CFG, (unsigned long)cfg);}int bios_eth_cfg(struct eth_cfg *cfg){ return bios_call(BIOSCALL_GET_ETHCFG, (unsigned long)cfg);}int bios_ne2000_cfg(struct ne2000_cfg *cfg){ return bios_call(BIOSCALL_GET_NE2000CFG, (unsigned long)cfg);}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_tftp_ipaddr(void){ unsigned long tftp_ipaddr; bios_call(BIOSCALL_GET_TFTPIPADDR, (unsigned long)&tftp_ipaddr); return tftp_ipaddr;}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_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);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -