LQ Newbie
Registered: Oct 2004
Posts: 13
Rep:
|
look at how i modify the system call interrupt vector
i want to modify the int 80 vector ,and i code it like this
#define MODULE
#define KERNEL
#define GFP_KERNEL 0
#define SYSCALL_VECTOR 0x80
#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
#define GDT_ENTRY_KERNEL_BASE 12
#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/config.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/types.h>
struct desc_struct {
unsigned long a,b;
};
void *kmalloc(ssize_t size,int flags);
int system_call(void);
int printk(const char *fmt,...);
void myvector(void)
{
char *save=(char *)kmalloc(30,GFP_KERNEL);
__asm__("movl %eax save \n\t"
"movl %ebx,save+1 \n\t"
"movl %ecx,save+2 \n\t"
"movl %edx,save+3 \n\t"
"movl %esi,save+4 \n\t"
"movl %edi,save+5");
printk("%s\n",*save);
__asm__ __volatile__("call *system_call");
//__asm__ __volatile__("movl $system_call,%eip");
}
void init_module(void)
{
extern struct desc_struct idt_table[256];
#define _set_gate(gate_addr,type,dpl,addr,seg) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
"movw %4,%%dx\n\t" \
"movl %%eax,%0\n\t" \
"movl %%edx,%1" \
:"=m" (*((long *) (gate_addr))), \
"=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
:"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
"3" ((char *) (addr)),"2" ((seg) << 16)); \
} while (0)
static void set_system_gate(unsigned int n, void *addr)
{
_set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
}
set_system_gate(SYSCALL_VECTOR,&myvector);
}
void cleanup_module(void)
{
extern struct desc_struct idt_table[256];
#define _set_gate(gate_addr,type,dpl,addr,seg) \
do { \
int __d0, __d1; \
__asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
"movw %4,%%dx\n\t" \
"movl %%eax,%0\n\t" \
"movl %%edx,%1" \
:"=m" (*((long *) (gate_addr))), \
"=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
:"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
"3" ((char *) (addr)),"2" ((seg) << 16)); \
} while (0)
static void set_system_gate(unsigned int n, void *addr)
{
_set_gate(idt_table+n,15,3,addr,__KERNEL_CS);
}
set_system_gate(SYSCALL_VECTOR,&system_call);
}
but when i compile it ,it say :myproject.c in function "myvector":
myproject.c:24:error:can't find a register in class "GENERAL_REGS" while reloading "asm"
what does this means?
i need your help,thanks!
|