osPfsIsPlug osPfsIsPlug (function)

Detects which Controller contains a Controller Pak


#include <ultra64.h>        /* os.h */
s32 osPfsIsPlug(OSMesgQueue *mq,  u8 *bitpattern);


The osPfsIsPlug detects which Controller contains a Controller Pak, and it returns the results as a bit pattern to the location pointed to by the bitpattern argument. Bits 0, 1, 2, and 3 of the bit pattern correspond to Controllers 1, 2, 3, and 4, respectively. A SI device has been inserted if a bit for each controller is on. If a bit is off that means 0, no device has been inserted for that controller.

The message queue specified by the mq argument must be the initialization completion message waiting in the queue associated with the OS_EVENT_SI event. For information on how to make this association, please see osSetEventMesg. Since mq is used by the function as an internal message queue, it is not necessary for the application to use mq for purposes such as queuing function-termination messages.

If the function is successfully called, a 0 is returned. Otherwise, -1 is returned.


In addition to osPfsIsPlug, some functions can be used to check the status of the Controller Pak which inculde osPfsInitPak, osContStartQuery, and osContGetQuery. There are, however, differences described below.

The osPfsIsPlug function issues a request command that checks the status of the Controller and Controller Pak. It checks all Controller sockets, converts the results to a bit pattern, and returns them.

In contrast, osPfsInitPak performs processing for only a single Controller. In addition to performing the Controller and Controller Pak status check that osPfsIsPlug performs, it also performs processing such as initializing the OSPfs structure, acquiring the Controller Pak ID and label areas, and calling the osPfsChecker function. As a result, it is very time consuming to call osPfsInitPak, compared to osPfsIsPlug, to determine whether the Controller Pak is inserted.

For simple status checking, the fastest approach is to use osContStartQuery and osContGetQuery. These functions perform the same processing as the osPfsIsPlug function does and they simplify the error checking process. Also they are a general-purpose function for all SI devices and can therefore also take parameters other than those used to detect whether a Pak-type SI device has been inserted. osPfsIsPlug should not be overused; osContStartQuery and osContGetQuery should be used instead whenever possible.


    OSMesgQueue     intMesgQueue;
    OSMesg          intMesgBuf[1];
    OSContStatus    sdata[MAXCONTROLLERS];
    u8              cont_pattern; 
    u8              pak_pattern; 

    osCreateMesgQueue(&intMesgQueue, intMesgBuf, 1);
    nosSetEventMesg(OS_EVENT_SI, &intMesgQueue, NULL);
    osContInit(&intMesgQueue, &cont_pattern, &sdata[0]);
    osPfsIsPlug(&intMesgQueue, &pak_pattern);

See Also

osContStartQuery, osContGetQuery, osPfsInitPak, osPfsAllocateFile, osPfsChecker, osPfsFileState, osPfsFreeBlocks, osPfsInitPak, osPfsReadWriteFile, osPfsSetLabel, and osSetEventMesg

Revision History

1999/02/01 Completely revised
1999/04/30 Changed format