Ask a question from expert

Ask now

The Implementation of the Standardized

14 Pages2981 Words845 Views
   

Added on  2019-09-16

The Implementation of the Standardized

   Added on 2019-09-16

BookmarkShareRelated Documents
//////////////////////////////////////////////////////////////////////////////////// File : cart_driver.c// Description : This is the implementation of the standardized IO functions// for used to access the CART storage system.//// Author : [Ishaank Chaudhary]// Last Modified : [10/24/2016]//// Includes#include <stdlib.h>// Project Includes#include "cart_driver.h"#include "cart_controller.h"#include "cmpsc311_log.h"#include "cmpsc311_util.h"//// Implementation//////////////////////////////////////////////////////////////////////////////////// Function : cart_poweron// Description : Startup up the CART interface, initialize filesystem//// Inputs : none// Outputs : 0 if successful, -1 if failurestruct {//structurechar file_name[CART_MAX_PATH_LENGTH];int file_status;//file status int file_desc;//file descriptorint length;int pos;int counter;}s[CART_MAX_TOTAL_FILES];static uint64_t oregstate,regstate, ky1,ky2,rt1,ct1,fm1;static int files;
The Implementation of the Standardized_1
//////////////////////////////////////////////////////////////////////////////////// Function : cart_poweron// Description : turn on the CART interface,//// Inputs : none// Outputs : 0 if successful, -1 if failureint32_t cart_poweron(void) {CartXferRegister regstate;if ((regstate = create_cart_opcode(CART_OP_INITMS, 0, 0, 0, 0)) == -1) { logMessage(LOG_ERROR_LEVEL, "CART driver failed: fail on power on."); return(-1); } oregstate = cart_io_bus(regstate, NULL); if (extract_cart_regstate(oregstate, &ky1, &ky2, &rt1, &ct1, &fm1)) { logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power on"); return(-1); } if (rt1){ logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power on"); return(-1); } for(int i = 0; i < CART_MAX_CARTRIDGES; i++){if ((regstate= create_cart_opcode(CART_OP_LDCART, 0, 0, i, 0)) == -1) { logMessage(LOG_ERROR_LEVEL, "CART driver failed: fail on power on"); return(-1); } oregstate = cart_io_bus(regstate, NULL); if (extract_cart_regstate(oregstate, &ky1, &ky2, &rt1, &ct1, &fm1)) { logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power on"); return(-1); } if (rt1){ logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power on"); return(-1); } if ((regstate= create_cart_opcode(CART_OP_BZERO, 0, 0, 0, 0)) == -1) { logMessage(LOG_ERROR_LEVEL, "CART driver failed: fail on power on"); return(-1); } oregstate = cart_io_bus(regstate, NULL); if (extract_cart_regstate(oregstate, &ky1, &ky2, &rt1, &ct1, &fm1)) {
The Implementation of the Standardized_2
logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power on" ); return(-1); } if (rt1){ logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power on"); return(-1); } }for(int j=0; j<CART_MAX_TOTAL_FILES;j++){strncpy(s[j].file_name,"\0",CART_MAX_PATH_LENGTH);s[j].pos=0;s[j].length=0;s[j].file_status =0;}// Return successfullyreturn(0);}//////////////////////////////////////////////////////////////////////////////////// Function : cart_poweroff// Description : Shut down the CART interface, close all files//// Inputs : none// Outputs : 0 if successful, -1 if failureint32_t cart_poweroff(void) {for(int i =0;i<CART_MAX_CARTRIDGES; i++){s[i].file_status =0;}if ((regstate= create_cart_opcode(CART_OP_POWOFF, 0, 0, 0, 0)) == -1) { logMessage(LOG_ERROR_LEVEL, "CART driver failed: fail on power off."); return(-1); }
The Implementation of the Standardized_3
oregstate = cart_io_bus(regstate, NULL); if (extract_cart_regstate(oregstate, &ky1, &ky2, &rt1, &ct1, &fm1)) { logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power off"); return(-1); } if (rt1){ logMessage(LOG_ERROR_LEVEL, "CART driver failed: failed: fail on power off"); return(-1); } // Return successfullyreturn(0);}//////////////////////////////////////////////////////////////////////////////////// Function : cart_open// Description : This function opens the file and returns a file handle//// Inputs : path - filename of the file to open// Outputs : file handle if successful, -1 if failureint16_t cart_open(char *path) {int i; for(i =0; i<files; i++){if(strncmp(s[i].file_name,path,CART_MAX_PATH_LENGTH)){if(s[i].file_status ==0){logMessage(LOG_ERROR_LEVEL, "FILE open failed: fail on cart open."); return -1;}else{s[i].file_status = 1;s[i].pos =0;return (i);}
The Implementation of the Standardized_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Desklib - Online Library for Study Material
|11
|2075
|276

C Programming Language Assignment
|44
|2042
|197

Sales Commission Calculator
|11
|610
|80

ITECH7410 Software Engineering Methodologies
|12
|980
|92