Executing a Minix kernel call

74 views Asked by At

I have followed this tutorial - https://wiki.minix3.org/doku.php?id=developersguide:newkernelcall to add a new kernel call, but how do I invoke it from a userspace program? I understand I should be able to use the syscall() function, but what arguments do I provide to it and what files do I need to include? Any help would be appreciated. Thanks

1

There are 1 answers

0
Howard Yang On

after followed https://wiki.minix3.org/doku.php?id=developersguide:newkernelcall to add a Kernel Call (SYS_SAMPLE 58) in Minix 3.4.0 rc6, I am using below code that basically coming from Example 1 of https://wiki.minix3.org/doku.php?id=developersguide:driverprogramming to test this Kernel Call 58

#include <stdio.h>
#include <stdlib.h>
#include <minix/syslib.h>
 
int main(int argc, char **argv)
{
    sef_startup();
 
    endpoint_t ept;
    unsigned flags;

    int r = sys_sample(flags, ept);
    
    printf("Hello, World %d!\n", r);
    return EXIT_SUCCESS;
}

process:

minix code is in /home/user/minix/src/minix/

  1. su // change to root
  2. cp /home/user/minix/src/minix/minix/include/minix/com.h /usr/include/minix/com.h // use modified com.h while making new kernel etc.
  3. cp /home/user/minix/src/minix/minix/include/minix/syslib.h /usr/include/minix/syslib.h

// make and use new kernel

  1. cd /boot/minix_default/
  2. mv kernel kernel.20240129 // back up original kernel
  3. cd /home/user/minix/src/minix/minix/kernel
  4. make
  5. cp kernel /boot/minix_default/kernel

// make and use new libsys.a

  1. cd /usr/lib
  2. mv libsys.a libsys.a.20240129
  3. mv libsys.so.0.0 libsys.so.0.0.20240129
  4. cd /home/user/minix/src/minix/minix/lib/libsys
  5. make
  6. cp libsys.a /usr/lib/libsys.a
  7. cp libsys.so.0.0 /usr/lib/libsys.so.0.0

// make and use new minix-service

  1. cd /sbin
  2. mv minix-service minix-service.20240129
  3. cd /home/user/minix/src/minix/minix/commands/minix-service
  4. make
  5. make install

//make and run test driver hello1

  1. reboot, then start Minix with Option "2"
  2. cd /home/user/minix/src/minix/minix/drivers/examples/hello1
  3. make clean
  4. make
  5. make install
  6. minix-service up /service/hello1
  7. minix-service down hello1

runnig result in Minix enter image description here although denied, seems called Kernel Call 58