redlar
02-08-2006, 06:52 AM
hello all,
these days I'm doing my homework which is the same to :
http://www.justlinux.com/forum/showthread.php?s=&postid=734635#post734635
I use RedHat 8 (Kernel 2.4.18-14)
that is adding 4 new kernel func() and syscalls to the kernel, I found the page above and that really helpful, but there still are some problems:
firstly In/usr/src/linux-2.4/include/linux/wait.h, I added
struct evnt_queue
{
struct evnt_queue *next_event;
wait_queue_head_t waitq;
int eid;
};
then added SYMBOL_NAME and the syscall Numbers to
/usr/src/linux-2.4.18-14/arch/i386/kernel/entry.S
&
/usr/src/linux-2.4.18-14/include/asm-i386/unistd.h
that's simple.
and in /usr/src/linux-2.4/init/main.c,added:
struct evnt_queue *eq;
static void __init event_init(void)
{
eq=(struct evnt_queue *)kmalloc(
sizeof(struct evnt_queue), GFP_KERNEL);
eq->next_event=NULL;
eq->eid=0;
init_waitqueue_head(&(eq->waitq));
}
asmlinkage void __init start_kernel(void)
{
......
event_init(); /* added as the last statement */
}
In /usr/src/linux/kernel/sys.c , added kernel func():
asmlinkage int sys_eventopen(int eid)
{
int newid=-1;
struct event_queue *temp;
printk("sys_eventopen");
if (eq==NULL)
{
eq=(struct event_queue *)kmalloc(
sizeof(struct event_queue), GFP_KERNEL);
eq->next_event=NULL;
eq->eid=0;
init_waitqueue_head(&(eq->waitq));
}
temp=eq->next_event;
if (eid>0)
{
while ((temp!=NULL)&&(temp->eid!=eid))
{
temp=temp->next_event;
}
if ((temp!=NULL)&&(temp->eid==eid)) newid=eid;
}
else if (eid==0)
{
while (temp!=NULL)
{
if (newid<temp->eid) newid=temp->eid;
temp=temp->next_event;
}
newid++;
if (newid<1) newid=1;
temp=(struct event_queue *)kmalloc(
sizeof(struct event_queue), GFP_KERNEL);
if (temp==NULL) newid=-1;
else
{
temp->eid=newid;
temp->next_event=eq->next_event;
eq->next_event=temp;
init_waitqueue_head(&(temp->waitq));
}
}
return(newid);
}
......
......
......
When "make bzImage", It stops at : 'eq' undeclared (when generating sys.o)
How should I do ...?
I'm sorry for being so verbose, and I'm really a rookie to the kernel programming
Thank you for any HELP !
these days I'm doing my homework which is the same to :
http://www.justlinux.com/forum/showthread.php?s=&postid=734635#post734635
I use RedHat 8 (Kernel 2.4.18-14)
that is adding 4 new kernel func() and syscalls to the kernel, I found the page above and that really helpful, but there still are some problems:
firstly In/usr/src/linux-2.4/include/linux/wait.h, I added
struct evnt_queue
{
struct evnt_queue *next_event;
wait_queue_head_t waitq;
int eid;
};
then added SYMBOL_NAME and the syscall Numbers to
/usr/src/linux-2.4.18-14/arch/i386/kernel/entry.S
&
/usr/src/linux-2.4.18-14/include/asm-i386/unistd.h
that's simple.
and in /usr/src/linux-2.4/init/main.c,added:
struct evnt_queue *eq;
static void __init event_init(void)
{
eq=(struct evnt_queue *)kmalloc(
sizeof(struct evnt_queue), GFP_KERNEL);
eq->next_event=NULL;
eq->eid=0;
init_waitqueue_head(&(eq->waitq));
}
asmlinkage void __init start_kernel(void)
{
......
event_init(); /* added as the last statement */
}
In /usr/src/linux/kernel/sys.c , added kernel func():
asmlinkage int sys_eventopen(int eid)
{
int newid=-1;
struct event_queue *temp;
printk("sys_eventopen");
if (eq==NULL)
{
eq=(struct event_queue *)kmalloc(
sizeof(struct event_queue), GFP_KERNEL);
eq->next_event=NULL;
eq->eid=0;
init_waitqueue_head(&(eq->waitq));
}
temp=eq->next_event;
if (eid>0)
{
while ((temp!=NULL)&&(temp->eid!=eid))
{
temp=temp->next_event;
}
if ((temp!=NULL)&&(temp->eid==eid)) newid=eid;
}
else if (eid==0)
{
while (temp!=NULL)
{
if (newid<temp->eid) newid=temp->eid;
temp=temp->next_event;
}
newid++;
if (newid<1) newid=1;
temp=(struct event_queue *)kmalloc(
sizeof(struct event_queue), GFP_KERNEL);
if (temp==NULL) newid=-1;
else
{
temp->eid=newid;
temp->next_event=eq->next_event;
eq->next_event=temp;
init_waitqueue_head(&(temp->waitq));
}
}
return(newid);
}
......
......
......
When "make bzImage", It stops at : 'eq' undeclared (when generating sys.o)
How should I do ...?
I'm sorry for being so verbose, and I'm really a rookie to the kernel programming
Thank you for any HELP !