Hello Guys.
This is my main 2 tasks of the project.
• Modify the appropriate device drivers in MINIX 3 such that when you
hit a special key (or ctrl-key sequence), it will echo a commonly used
string including those for shell commands. You should be able to echo
the string in any position of a command line indicated by the cursor,
and the command line should be executable.
• Write a program to associate the special keys with the strings. You
should be able to associate 5 special keys for 5 different strings and
you can change the association later.
I am done with associating the keys with the strings and echoing them
however the trickier part of my project is to changing string
association later.
Like if ctrl+f -> fav1.c
I must be able change that association to fav2.c or any user given
string.
For that I need to write an app program calling a system call which
will pass the string to File system.
I gone through the driver source code and found a way to pass the data
from FS process to Driver process.
After I get the user value(using system call) in to the FS, in the
do_myfunc() I send a message to driver as follows
*********************************************************************************************************************
message mess /*has the value to pass to driver*/
_sendrec(TTY_PROC_NR, &mess); /*#define TTY_PROC_NR 5 /*
terminal (TTY) driver */
**********************************************************************************************************************
Then in the driver i.e tty.c am thinking of using do_ioctl:
***********************************************************************************************************************
code snippets from tty.c which i
deal with
************************************************************************************************************************
00200 /* Get a request message. */
00163 message tty_mess; /* buffer for all incoming
messages */
00201 r= receive(ANY, &tty_mess);
00202 if (r != 0)
00203 panic("TTY", "receive failed with %d", r);
00308 /* Execute the requested device driver function. */
00309 switch (tty_mess.m_type) {
00310 case DEV_READ: do_read(tp,
&tty_mess); break;
00311 case DEV_WRITE: do_write(tp,
&tty_mess); break;
00312 case DEV_IOCTL: do_ioctl(tp,
&tty_mess); break; /*a process wants to change a terminal's
parameters*/
00313 case DEV_OPEN: do_open(tp,
&tty_mess); break;
00314 case DEV_CLOSE: do_close(tp,
&tty_mess); break;
00315 case DEV_SELECT: do_select(tp,
&tty_mess); break;
00316 case CANCEL: do_cancel(tp,
&tty_mess); break;
00317 default:
00318 printf("Warning, TTY got unexpected request %d
from %d\n",
00319 tty_mess.m_type, tty_mess.m_source);
00320 tty_reply(TASK_REPLY, tty_mess.m_source,
00321
tty_mess.IO_ENDPT, EINVAL);
*****************************************************************************************************************************
i can add do_ioctl()
*****************************************************************************************************************************
before this i modify the struct terminos to add char array to store my
new string.
00014 struct termios {
00015 tcflag_t c_iflag; /* input modes */
00016 tcflag_t c_oflag; /* output modes */
00017 tcflag_t c_cflag; /* control modes */
00018 tcflag_t c_lflag; /* local modes */
00019 speed_t c_ispeed; /* input speed */
00020 speed_t c_ospeed; /* output speed */
00021 cc_t c_cc[NCCS]; /* control characters */
00022 newSting[STR_SIZ]; /*Place where I copy the new
String that is passed by FS*/
00022 };
While I am going through the below code i am wondering why "D" is in
place of src_seg...
00533 PRIVATE void do_ioctl(tp, m_ptr)
{
00622 case TCSETS:
00623 /* Set the termios attributes. */
00624 r = sys_vircopy( m_ptr->IO_ENDPT, D, (vir_bytes) m_ptr-
>ADDRESS, /*here D is #defined in commands/simple/mail.c*/
00625 SELF, D, (vir_bytes) &tp->tty_termios,
(vir_bytes) size);
00626 if (r != OK) break;
00627 setattr(tp);
00628 break;
}
/* PUBLIC int sys_vircopy (int src_proc, int src_seg, vir_bytes
src_vir, int dst_proc, int dst_seg, (vir_bytes)dst_vi, (phys_bytes)
bytes); */
actually it is defined in commands/simple/mail.c(http://
www.raspberryginger.com/jbailey/minix/html/simple_2mail_8c-source.html#l00024)
as below:
/*
00021 #ifdef DEBUG
00022 #define D(Q) (Q)
00023 #else
00024 #define D(Q)
00025 #endif
*/
Please let me know whether my approach is correct, like passing user
data via File system, am modifying struct termios…is it safe to do
so.
Please let me know if any better approach available, like is it
possible to write a system call which directly passes the user data
into driver memory address space.
References:
For the minix Source code:
http://www.raspberryginger.com/jbailey/minix/html/files.html
Thank You
Sincerely,
Harinath