osPfsInit

osPfsInit

Function

osPfsInit

Initializes the Controller Pak file handle

Syntax

#include <ultra64.h>
s32 osPfsInit(OSMesgQueue *mq, OSPfs *pfs, int controller_no);

Description

Warning: Please use osPfsInitPak, instead of this (as of Feb 15, 1997).

A file system called PFS is used in the Controller Pak. This system is partitioned into 32-byte units and managed in units of this size. The maximum size of the PFS file system is currently 32K bytes.

When the PFS function is used to control the file system, the OSPfs structure pointed to by the pfs argument is used like a file handle to access files. This function (osPfsInit) initializes that OSpfs structure. The controller_no argument specifies the number of the controller (0-3) into which the Controller Pak is inserted. The message queue (mq) argument is the queue used while waiting for the message indicating that initialization is finished. It is associated with OS_EVENT_SI. For information on how to make this association, please see osSetEventMesg. Because the function (osPfsInit) waits internally for the message queue (mq), this queue must not be shared. In addition, because of synchronous initialization at a low level of the OS, you must call osContInit before calling this function (osPfsInit).

If this function is called successfully, 0 is returned. If an error occurs, one of the following error codes is returned:

PFS_ERR_NOPACK
Either the Controller Pak is not inserted into the specified Controller or the Controller is not properly connected. To determine which is the case, use osContStartQuery or osContGetQuery.
PFS_ERR_NEW_PACK
A different Controller Pak has been inserted. To use the inserted Controller Pak, initialize it by calling osPfsInitPak.
PFS_ERR_CONTRFAIL
Data transfer to or from the Controller has failed. If a transfer error occurs, up to three tries will be done internally. Therefore, it is rather rare to see this error. If this error has returned, it is possible that either the Controller is not connected properly, or the Controller Pak or Controller Socket is damaged.
PFS_ERR_ID_FATAL
The Controller Pak's ID area is destroyed. Although it attempted to repair the destroyed area, it failed. The Controller Pak is damaged, not connected properly, or a device that without SRAM has been inserted.
PFS_ERR_DEVICE
When it initializes the file syste, the device ID in the ID area located in Page 0 is checked. However, no device ID was found. In other words, a device other than Controller pak has been inserted to the controller.

Example

main()
{
        OSMesgQueue        intMesgQueue;
        OSMesg                intMesgBuf[1];
        OSContStatus        sdata[MAXCONTROLLERS];
        u8                cont_pattern, pak_pattern;
        OSPfs                pfs[MAXCONTROLLERS];

        osCreateMesgQueue(&intMesgQueue, intMesgBuf, 1);

        osSetEventMesg(OS_EVENT_SI, &intMesgQueue, dummyMessage);
        osContInit(&intMesgQueue, &cont_pattern, &sdata[0]);
        osPfsIsPlug(&intMesgQueue, &pak_pattern);
        for (i = 0; i < MAXCONTROLLERS; i++) {
                if (pak_pattern & (1<<i)){
                        ret = osPfsInit(&pifMesgQueue, &pfs[i], i);
                }
                if ((ret == PFS_ERR_ID_FATAL) ||(ret == PFS_ERR_DEVICE))

                pak_pattern &= ~(1<<i);
        }
}

See Also

osContInit, osContStartQuery, osContGetQuery, and osPfsInitPak