Reputation: 83
I'm trying to use "int $0x1a" to have bios call, to search PCI device in Linux. It's implemented in C language with inline assembly. The code shows below:
#include<stdio.h>
int findpci(int device_id, int plx_id){
int result;
__asm__(
"pushl %%eax \n\t"
"pushl %%ebx \n\t"
"pushl %%ecx \n\t"
"pushl %%edx \n\t"
"pushl %%esi \n\t"
"movl $0xb102, %%eax \n\t"
"movl %2, %%ecx \n\t"
"movl %3, %%edx \n\t"
"movl $0x0000, %%esi \n\t"
"int $0x1a \n\t"
"movl %%ebx, %0 \n\t"
"movb %%ah, %1 \n\t"
"popl %%esi \n\t"
"popl %%edx \n\t"
"popl %%ecx \n\t"
"popl %%ebx \n\t"
"popl %%eax \n\t"
:"=r"(result), "=r"(flag)
:"r"(device_id), "r"(plx_id)
);
return result;
}
int main(){
int c = findpci(0x9050, 0x10B5);
printf("%d\n", c);
return 0;
}
But I got "segmentation fault(core dump)". What's wrong with my code. Is that it could not call "int $0x1a" in the system?
Upvotes: 1
Views: 199
Reputation: 609
Is that it could not call "int $0x1a" in the system?
Yes, it's not possible to do BIOS calls from Linux programs. I suggest you look at the lspci
program instead.
Upvotes: 1