404 Not Found
404 Not Found

Reputation: 3665

Minix - System call not correctly calling function?

I need to create a system call in Minix for a homework assignment. I've gotten most of the set up finished, but for some reason the function that the system call is actually calling isn't being found correctly. (Pardon any bad wording choices, I'm not sure the best words to explain this).

I've created a mylib.h in /usr/include (and /usr/src/include), with the following code:

#include <lib.h>
#include <unistd.h>
#include <stdio.h>

int mycall(){
    message m;
    return (_syscall(PM_PROC_NR, MYCALL, &m));
}

I also added mylib.h to the appropriate Makefile.

I've defined MYCALL in /usr/src/include/minix/callnr.h, and I've added do_mycall to the corresponding slot in /usr/src/servers/pm/table.h.

I've added int do_mycall(void); to /usr/src/servers/pm/proto.h, and I added a simple function declaration in misc.c.

int do_mycall(void){
    printf("I've been called");
    return 0;
}

I've also tried placing it in it's own .c file, which I added to the Makefile in that directory.

I performed make in /usr/src/servers/pm/ and /usr/src/include, and make includes in /usr/src/releasetools.

However, when I call mycall(), and catch the return value, it's -1.

I've added some prints, and I can tell that the function in mylib.h is being called, and MYCALL is correctly defined as the index in table.h, and table.h should have the do_mycall line correctly in place (though I don't really know how to test that it's there upon execution). So, all I can tell is that in _syscall, do_mycall isn't correctly mapping to it's function.

I tried replacing the prototype in photo.h with just the code in misc.c (so the prototype would be missing), but nothing happened differently, and make didn't complain.

Can anyone help me figure out what's causing this, or how I can narrow down where the disconnect is here?

If anyone knows where _syscall is defined, that might help, since I could maybe add some prints in it to figure out how far it's getting.

Upvotes: 1

Views: 1967

Answers (1)

404 Not Found
404 Not Found

Reputation: 3665

I was unable to find a specific cause, but after exhausting all options I could find, the issue appears to have been with my virtual machine. I repeated everything I did to set up the system call on VMware Player, instead of VirtualBox, and everything worked fine.

Upvotes: 1

Related Questions