请问在C语言中,头文件bios.h有什么用?

请问在C语言中,头文件bios.h有什么用?,第1张

bios.h头文件定义了硬件端口和公共函数,可以调用相关的函数进行端口设备的访问。不过对BIOS设备的访问只限于DOS实模式系统,此文件对保护模式的支持不够强大。

如biosdisk()函数,用它可以访问硬盘扇区;

biosmemory()函数获得内存大小等等:

#include <stdio.h>

#include <bios.h>

int main(void) /* C90标准不支持这种写法,所以最好用支持C99标准的编译器编译 */

{

 int memory_size

 memory_size = biosmemory()/* returns value up to 640K */

 printf("RAM size = %dK\n",memory_size)

 return 0

}

bios.h 涉及输入输出的头文件,与软件和硬件都有关系,网上可以搜到bios.h,但你要判断是否是你需要的。例如 linux 的:

#ifndef _ASM_X86_UV_BIOS_H

#define _ASM_X86_UV_BIOS_H

#include <linux/rtc.h>

/*

* Values for the BIOS calls. It is passed as the first * argument in the

* BIOS call. Passing any other value in the first argument will result

* in a BIOS_STATUS_UNIMPLEMENTED return status.

*/

enum uv_bios_cmd {

UV_BIOS_COMMON,

UV_BIOS_GET_SN_INFO,

UV_BIOS_FREQ_BASE,

UV_BIOS_WATCHLIST_ALLOC,

UV_BIOS_WATCHLIST_FREE,

UV_BIOS_MEMPROTECT,

UV_BIOS_GET_PARTITION_ADDR

}

/*

* Status values returned from a BIOS call.

*/

enum {

BIOS_STATUS_MORE_PASSES = 1,

BIOS_STATUS_SUCCESS = 0,

BIOS_STATUS_UNIMPLEMENTED = -ENOSYS,

BIOS_STATUS_EINVAL = -EINVAL,

BIOS_STATUS_UNAVAIL = -EBUSY

}

/*

* The UV system table describes specific firmware

* capabilities available to the Linux kernel at runtime.

*/

struct uv_systab {

char signature[4] /* must be "UVST" */

u32 revision /* distinguish different firmware revs */

u64 function /* BIOS runtime callback function ptr */

}

enum {

BIOS_FREQ_BASE_PLATFORM = 0,

BIOS_FREQ_BASE_INTERVAL_TIMER = 1,

BIOS_FREQ_BASE_REALTIME_CLOCK = 2

}

union partition_info_u {

u64 val

struct {

u64 hub_version : 8,

partition_id : 16,

coherence_id : 16,

region_size : 24

}

}

union uv_watchlist_u {

u64 val

struct {

u64 blade : 16,

size : 32,

filler : 16

}

}

enum uv_memprotect {

UV_MEMPROT_RESTRICT_ACCESS,

UV_MEMPROT_ALLOW_AMO,

UV_MEMPROT_ALLOW_RW

}

/*

* bios calls have 6 parameters

*/

extern s64 uv_bios_call(enum uv_bios_cmd, u64, u64, u64, u64, u64)

extern s64 uv_bios_call_irqsave(enum uv_bios_cmd, u64, u64, u64, u64, u64)

extern s64 uv_bios_call_reentrant(enum uv_bios_cmd, u64, u64, u64, u64, u64)

extern s64 uv_bios_get_sn_info(int, int *, long *, long *, long *)

extern s64 uv_bios_freq_base(u64, u64 *)

extern int uv_bios_mq_watchlist_alloc(int, unsigned long, unsigned int,

unsigned long *)

extern int uv_bios_mq_watchlist_free(int, int)

extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect)

extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *)

extern void uv_bios_init(void)

extern unsigned long sn_rtc_cycles_per_second

extern int uv_type

extern long sn_partition_id

extern long sn_coherency_id

extern long sn_region_size

#define partition_coherence_id() (sn_coherency_id)

extern struct kobject *sgi_uv_kobj /* /sys/firmware/sgi_uv */

#endif /* _ASM_X86_UV_BIOS_H */


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12095960.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-21
下一篇 2023-05-21

发表评论

登录后才能评论

评论列表(0条)

保存