MP3 1.0
This is the Doxygen document for ECE391 MP3.
Loading...
Searching...
No Matches
Functions | Variables
file_descriptor.c File Reference

Implementations for file descriptors. More...

#include "types.h"
#include "file_descriptor.h"
#include "pcb.h"

Functions

int32_t dummyRead ()
 
int32_t dummyWrite ()
 
int32_t dummyOpen ()
 
int32_t dummyClose ()
 
void createBlankFileDescriptor (fd_t *fileDescriptor)
 Create a Blank File Descriptor. More...
 
void initFileDescriptor (fd_t *fileDescriptor)
 Initializes the fileDescriptor given by setting stdin and stdout files. More...
 
void destroyFileDescriptor (fd_t *fileDescriptor)
 Destroy a file descriptor. More...
 

Variables

fileOp_t rtcFileOps
 
fileOp_t stdinFileOps
 
fileOp_t stdoutFileOps
 
fileOp_t dataFileOps
 
fileOp_t directoryFileOps
 
fileOp_t dummyFileOp
 

Detailed Description

Implementations for file descriptors.

Author
Group 8
Date
2023-03-25

Function Documentation

◆ createBlankFileDescriptor()

void createBlankFileDescriptor ( fd_t fileDescriptor)

Create a Blank File Descriptor.

Used in initFileDescriptor and when closing system calls.

Parameters
fileDescriptorThe file descriptor to be initialized as blank.

◆ destroyFileDescriptor()

void destroyFileDescriptor ( fd_t fileDescriptor)

Destroy a file descriptor.

Parameters
fileDescriptorThe file descriptor to be completely wiped out.

◆ dummyClose()

int32_t dummyClose ( )
inline

◆ dummyOpen()

int32_t dummyOpen ( )
inline

◆ dummyRead()

int32_t dummyRead ( )
inline

◆ dummyWrite()

int32_t dummyWrite ( )
inline

◆ initFileDescriptor()

void initFileDescriptor ( fd_t fileDescriptor)

Initializes the fileDescriptor given by setting stdin and stdout files.

Parameters
fileDescriptorthe file descriptor to be initialized.

Variable Documentation

◆ dataFileOps

fileOp_t dataFileOps
Initial value:
=
{
.read = readFile,
.write = writeFile,
.open = openFile,
.close = closeFile
}
int readFile(int32_t fd, void *buf, int32_t nbytes)
Read a file given the file descriptor index.
Definition: filesystem.c:341
int openFile(const uint8_t *filename)
Open a file.
Definition: filesystem.c:377
int writeFile(int32_t fd, const void *buf, int32_t nbytes)
Write to a file.
Definition: filesystem.c:364
int closeFile(int32_t fd)
Close a file.
Definition: filesystem.c:390

◆ directoryFileOps

fileOp_t directoryFileOps
Initial value:
=
{
.read = readDirectory,
.write = writeDirectory,
.open = openDirectory,
.close = closeDirectory
}
int writeDirectory(int32_t fd, const void *buf, int32_t nbytes)
Write to a directory.
Definition: filesystem.c:271
int openDirectory(const uint8_t *filename)
open a directory.
Definition: filesystem.c:284
int readDirectory(int32_t fd, void *buf, int32_t nbytes)
Read a directory.
Definition: filesystem.c:226
int closeDirectory(int32_t fd)
close a directory.
Definition: filesystem.c:298

◆ dummyFileOp

fileOp_t dummyFileOp
Initial value:
=
{
.read = dummyRead,
.write = dummyWrite,
.open = dummyOpen,
.close = dummyClose
}
int32_t dummyClose()
Definition: file_descriptor.c:16
int32_t dummyWrite()
Definition: file_descriptor.c:14
int32_t dummyOpen()
Definition: file_descriptor.c:15
int32_t dummyRead()
Definition: file_descriptor.c:13

◆ rtcFileOps

fileOp_t rtcFileOps
Initial value:
=
{
.read = rtcRead,
.write = rtcWrite,
.open = rtcOpen,
.close = rtcClose
}
int32_t rtcOpen(const uint8_t *filename)
Sets the RTC to its slowest rate. (2Hz)
Definition: rtc.c:207
int32_t rtcClose(int32_t fd)
Needed per MP spec.
Definition: rtc.c:220
int rtcRead(int32_t fd, void *buf, int32_t nbytes)
Other functions will use this to tell when an RTC interrupt occurs.
Definition: rtc.c:238
int rtcWrite(int32_t fd, const void *buf, int32_t nbytes)
Set the rate of the RTC thru a sys call.
Definition: rtc.c:261

◆ stdinFileOps

fileOp_t stdinFileOps
Initial value:
=
{
.read = terminalRead,
.write = NULL,
.open = terminalOpen,
.close = terminalClose
}
int terminalRead(int32_t fd, void *buf, int32_t nbytes)
Start recording key presses. Ends when enter is pressed.
Definition: terminal.c:52
int terminalClose(int32_t fd)
Close terminal.
Definition: terminal.c:105
int terminalOpen(const uint8_t *filename)
Open Terminal.
Definition: terminal.c:92
#define NULL
Definition: types.h:13

◆ stdoutFileOps

fileOp_t stdoutFileOps
Initial value:
=
{
.read = NULL,
.write = terminalWrite,
.open = terminalOpen,
.close = terminalClose
}
int terminalWrite(int32_t fd, const void *buf, int32_t nbytes)
Write output arg buffer to the screen.
Definition: terminal.c:26