| 12345678910111213141516171819202122232425262728293031 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/io.h>
- #include <stdint.h>
- #include <string.h>
- int main(void)
- {
- unsigned char val;
- if (ioperm(0x80, 1, 1) < 0) { //申请 0x80 端口的访问权限
- perror("Failed to request I/O port permission");
- return 1;
- }
- /*
- outb(0x00,0xA45);
- outb(inb(0xA46) | 0x40, 0xA46);//update VBAT
- outb(0x00,0xEB);
- outb(0x00,0xEB);
- outb(0x00,0xEB);
- outb(0x28,0xA45);
- val = inb(0xA46);//read VBAT
- */
- outb(0x88, 0x80); //用户空间也有 outb 函数(需链接 libx86)
- ioperm(0x80,1,0); //释放权限
- //printf("VBAT value = %dmv\n", val * 2 * 11);
- return 0;
- }
|