punk@13: #include punk@13: #include punk@13: #include punk@13: #include punk@13: #include punk@13: #include punk@13: punk@13: #include "asim/rrr/service_ids.h" punk@13: punk@13: #include "asim/provides/connected_application.h" punk@13: punk@13: using namespace std; punk@13: punk@13: // ===== service instantiation ===== punk@13: AUDIOCORERRR_SERVER_CLASS AUDIOCORERRR_SERVER_CLASS::instance; punk@13: punk@13: // constructor punk@13: AUDIOCORERRR_SERVER_CLASS::AUDIOCORERRR_SERVER_CLASS() : punk@15: serverStub(new AUDIOCORERRR_SERVER_STUB_CLASS(this)) punk@13: { punk@13: // instantiate stub rlm@23: rlm@23: printf("rlm: init called\n\n"); punk@13: outputFile = NULL; punk@13: memory = NULL; punk@13: fflush(stdout); punk@13: } punk@13: punk@13: // destructor punk@13: AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS() punk@13: { rlm@23: printf("rlm: AUDIOCORERRR_SERVER_CLASS::~AUDIOCORERRR_SERVER_CLASS()\n"); punk@13: Cleanup(); punk@13: } punk@13: punk@13: // init punk@13: void punk@13: AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p) punk@13: { rlm@23: printf("rlm: AUDIOCORERRR_SERVER_CLASS::Init(PLATFORMS_MODULE p)\n"); rlm@23: parent = p; punk@13: } punk@13: punk@13: // uninit punk@13: void punk@13: AUDIOCORERRR_SERVER_CLASS::Uninit() punk@13: { rlm@23: printf("rlm: AUDIOCORERRR_SERVER_CLASS::Uninit()\n"); rlm@23: Cleanup(); punk@13: } punk@13: punk@13: // cleanup punk@13: void punk@13: AUDIOCORERRR_SERVER_CLASS::Cleanup() punk@13: { rlm@23: printf("rlm: AUDIOCORERRR_SERVER_CLASS::Cleanup() \n\n"); rlm@23: delete serverStub; punk@13: } punk@13: punk@13: punk@13: // punk@13: // RRR service methods punk@13: // punk@13: punk@13: UINT32 punk@13: AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address) punk@13: { punk@13: UINT32 returnVal; rlm@23: printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestLoad (UINT32 address)\n"); punk@13: if(memory == NULL) { punk@13: memory = new FUNCP_SIMULATED_MEMORY_CLASS(); punk@13: } punk@13: punk@13: punk@13: memory->Read(0,(UINT64) address, sizeof(UINT32), &returnVal); punk@13: return returnVal; punk@13: } punk@13: punk@13: void punk@13: AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data) punk@13: { rlm@23: printf("rlm: AUDIOCORERRR_SERVER_CLASS::MemoryRequestStore (UINT32 address, UINT32 data)\n"); punk@13: if(memory == NULL) { punk@13: memory = new FUNCP_SIMULATED_MEMORY_CLASS(); punk@13: } punk@13: punk@13: memory->Write(0,(UINT64) address, sizeof(UINT32), &data); punk@22: } punk@13: punk@13: void punk@13: punk@13: AUDIOCORERRR_SERVER_CLASS::SendProcessedStream(UINT16 control, UINT16 data) punk@13: { punk@13: punk@25: // printf("rlm: SendProcessedStream called,\n"); punk@13: AudioProcessorControl audioProcessorControl = (AudioProcessorControl) control; punk@13: switch(control) { punk@13: case EndOfFile: punk@13: if(outputFile != NULL) { rlm@23: printf("rlm: FILE is NULL\n"); punk@13: fflush(outputFile); punk@13: fclose(outputFile); punk@13: outputFile = NULL; punk@13: } else { rlm@23: printf("rlm: Opening file for output.\n"); punk@13: outputFile = fopen("out_hw.pcm","w"); punk@13: assert(outputFile); punk@13: fflush(outputFile); punk@13: fclose(outputFile); punk@13: } punk@13: punk@13: // Long term this should be in the data portion. But until I have code running, keep it here. punk@13: CONNECTED_APPLICATION_CLASS::EndSimulation(); punk@13: break; punk@13: punk@13: case Data: punk@13: if(outputFile == NULL) { punk@13: outputFile = fopen("out_hw.pcm","w"); punk@13: assert(outputFile); punk@13: } punk@13: rlm@23: CONNECTED_APPLICATION_CLASS::UpdateSemaphore(); punk@25: // printf("rlm: writing data to out_hw.pcm\n"); punk@13: fwrite(&data, 2,1 , outputFile); punk@13: break; punk@13: } punk@13: }