static int _vrpc_server_thread (void* data) { vrpc_t* vrpc = (vrpc_t*) data; DTRACE("VLINK %d (%d -> %d) [%s] server thread started\n", vrpc->vlink->link, vrpc->vlink->c_id, vrpc->vlink->s_id, (vrpc->my.info ? vrpc->my.info : "")); for (;;) { if (wait_event_interruptible(vrpc->wait, _vrpc_server_thread_wakeup(vrpc))) { break; } if (_aborted || !vrpc->open) { break; } _vrpc_direct_call(vrpc); } DTRACE("VLINK %d (%d -> %d) [%s] server thread stopped\n", vrpc->vlink->link, vrpc->vlink->c_id, vrpc->vlink->s_id, (vrpc->my.info ? vrpc->my.info : "")); while (!kthread_should_stop()) { set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(1); } return 0; }
struct thread_read *new_thread_read(const char *url, const char *headers, int flags) { pthread_t tid; pthread_attr_t pthread_attr; struct thread_read *thread; int ret; DTRACE(); thread = malloc(sizeof(struct thread_read)); if (!thread) { return NULL; } memset(thread, 0, sizeof(*thread)); DTRACE(); thread->streambuf = streambuf_alloc(0); if (!thread->streambuf) { free(thread); return NULL; } DTRACE(); pthread_attr_init(&pthread_attr); pthread_attr_setstacksize(&pthread_attr, 409600); //default joinable pthread_mutex_init(&thread->pthread_mutex, NULL); pthread_cond_init(&thread->pthread_cond, NULL); thread->url = url; thread->flags = flags; thread->headers = headers; thread->max_read_seek_len = MAX_READ_SEEK; thread->toreadblocksize=32*1024; thread->readtotalsize=0; thread->readcnt=0; ret = pthread_create(&tid, &pthread_attr, (void*)&thread_read_thread_run, (void*)thread); thread->pthread_id = tid; return thread; }
AST_Pipeline_t *AST_ParseExpressionOrAssignment(Parser_t *parser) { AST_Pipeline_t *pipeline; Token_t *cmd_or_var; DTRACE("%s: Start\n", __func__); if ((pipeline = calloc(1, sizeof(*pipeline))) == NULL) { return NULL; } cmd_or_var = parser->t; Scanner_TokenAccept(parser); if (parser->t->type == TOKEN_EQUALS) { pipeline->assignment = AST_ParseAssignment(parser, cmd_or_var); } else { pipeline->expression = AST_ParseExpression(parser, cmd_or_var); } if (parser->t->type == TOKEN_SEMICOLON) { Scanner_TokenConsume(parser); } DTRACE("%s: End\n", __func__); return pipeline; }
static int vaudio_send_data (struct vaudio_stream* s) { NkDevRing* ring = s->ring; const nku32_f oreq = ring->ireq; const nku32_f nreq = oreq + 1; const nku32_f mask = ring->imask; NkRingDesc* desc = s->rbase + (oreq & mask); bool xirq_trigger = 0; struct snd_pcm_runtime* runtime = s->stream->runtime; if ((ring->iresp & mask) == (ring->ireq & mask)) { DTRACE ("ring empty\n"); xirq_trigger = 1; } if ((nreq & mask) == (ring->iresp & mask)) { DTRACE ("ring full\n"); return -ENOMEM; } ring->ireq = nreq; desc->status = NK_VAUDIO_STATUS_OK; desc->bufsize = frames_to_bytes(runtime, runtime->period_size); #ifdef VAUDIO_CONFIG_NK_PMEM desc->bufaddr = s->stream->dma_buffer.addr + desc->bufsize * s->period; #else desc->bufaddr = nkops.nk_vtop(runtime->dma_area + desc->bufsize * s->period); #endif DTRACE ("%x %x\n", desc->bufaddr, desc->bufsize); s->period++; s->period %= runtime->periods; return xirq_trigger; }
static void rsa_test_code() { DTRACE("\n\n== rsa_test_code ==\n"); DTRACE("encrypt public, decrypt private \n"); char *cipher = encrypt_publickey_fromcode(gTestData0); if (cipher != NULL) { char *plaintext = decrypt_privatekey_fromcode(cipher); if (plaintext != NULL) { DEBUG("The plaintext = %s \n", plaintext); free(plaintext); plaintext = NULL; } free(cipher); cipher = NULL; } DTRACE("\n\n encrypt private, decrypt public\n"); cipher = encrypt_privatekey_fromcode(gTestData0); if (cipher != NULL) { char *plaintext = decrypt_publickey_fromcode(cipher); if (plaintext != NULL) { DEBUG("The plaintext = %s \n", plaintext); free(plaintext); plaintext = NULL; } free(cipher); cipher = NULL; } }
static void rsa_test_file() { DEBUG("\n\n== rsa_test_file ==\n"); DTRACE("encrypt public, decrypt private \n"); char *cipher = encrypt_publickey_fromfile(gTestData0, PUBLIC_KEY_FILE); if (cipher != NULL) { char *plaintext = decrypt_privatekey_fromfile(cipher, PRIVATE_KEY_FILE); if (plaintext != NULL) { DEBUG("The plaintext = %s \n", plaintext); free(plaintext); } free(cipher); } DTRACE("\n\n encrypt private, decrypt public\n"); cipher = encrypt_privatekey_fromfile(gTestData0, PRIVATE_KEY_FILE); if (cipher != NULL) { char *plaintext = decrypt_publickey_fromfile(cipher, PUBLIC_KEY_FILE); if (plaintext != NULL) { DEBUG("The plaintext = %s \n", plaintext); free(plaintext); plaintext = NULL; } free(cipher); cipher = NULL; } }
/******************************************************************************* * Name: get_bsm * * Desc: Searches through the BS table and returns a free BS id. * * Params: * avail - pointer to store the free BS id * * Returns: SYSCALL * OK - on success * SYSERR - on error or if no free BS is available ******************************************************************************/ SYSCALL get_bsm(int* avail) { uint8_t bs_id = 0; bs_map_t *bsptr = NULL; STATWORD ps; disable(ps); DTRACE_START; if (NULL == avail) { DTRACE("DBG$ %d %s> null pointer: avail\n", currpid, __func__); goto RESTORE_AND_RETURN_ERROR; } for (bs_id = 0; bs_id < BS_NUM; ++bs_id) { if BS_IS_FREE(bs_id) { DTRACE("DBG$ %d %s> bs id %d is free\n", currpid, __func__, bs_id); *avail = bs_id; bsptr = BS_GET_PTR(bs_id); bsptr->bsm_status = BS_INUSE; restore(ps); DTRACE_END; return OK; } } DTRACE("DBG$ %d %s> no free bs id is available\n", currpid, __func__); *avail = EMPTY; RESTORE_AND_RETURN_ERROR: DTRACE("DBG$ %d %s> returning SYSERR\n", currpid, __func__); restore(ps); DTRACE_END; return SYSERR; }
/* Name: l_is_lid_stale_for_pid * * Desc: Checks whether the lid is stale for the given pid. This happens when * a process hasn't acquired a lock after create/release for a long time * and the lock Id has been overflown in the system. * * Params: * lid - lock ID (as known by the old proc) * pid - proc ID of the old proc * * Returns: int * TRUE - if the lid has been overflown for the given pid * FALSE - if the lid is still valid for the given pid */ int l_is_lid_stale_for_pid(lid, pid) { STATWORD ps; disable(ps); DTRACE_START; /* Check the pid in the lid's delpidmap. If present, our guy still thinks * that he owns the lid. Well, he doesn't. Return TRUE. */ if (TRUE == l_pidmap_oper(lid, pid, L_MAP_DELETE, L_MAP_CHK)) { DTRACE("DBG$ %d %s> lid %d is stale for pid %d\n", \ currpid, __func__, lid, pid);; DTRACE_END; restore(ps); return TRUE; } DTRACE("DBG$ %d %s> lid %d is not stale for pid %d\n", \ currpid, __func__, lid, pid);; DTRACE_END; restore(ps); return FALSE; }
/* Name: l_new_lid * * Desc: Scans the lock table and returns the next available free lock. * * Params: * None * * Returns: int * Next available lock ID on success * SYSERR on failure. */ int l_new_lid (void) { int i = 0; int ret_lid = 0; DTRACE_START; for (i = 0; i < NLOCKS; ++i) { /* Run thru all available lock IDs until we find one which we can * use, i.e., a lock whose state is either LS_UNINIT or LS_DELETED. */ ret_lid = next_lock--; if (next_lock < 0) { DTRACE("DBG$ %d %s> next_lock overflowed.. resetting next_lock"\ " to %d\n", currpid, __func__, (NLOCKS - 1)); next_lock = (NLOCKS - 1); } if (LS_UNINIT == L_GET_LSTATE(ret_lid) || (LS_DELETED == L_GET_LSTATE(ret_lid))) { DTRACE("DBG$ %d %s> lid %d state changed from %s to Free %d\n", \ currpid, __func__, ret_lid, L_GET_LSTATESTR(ret_lid)); L_SET_LSTATE(ret_lid, LS_FREE); DTRACE("DBG$ %d %s> returning lock %d\n", \ currpid, __func__, ret_lid); DTRACE_END; return ret_lid; } } DTRACE("DBG$ %d %s> no more free locks\n", currpid, __func__); DTRACE_END; return SYSERR; }
void AST_PrintList(AST_List_t *pipeline_list) { int i; DTRACE("=======================================\n"); for (i = 0; i < pipeline_list->npipelines; i++) { AST_PrintPipeline(pipeline_list->pipelines[i]); } DTRACE("=======================================\n"); }
/******************************************************************************* * Name: pgt_update_all * * Desc: Called when a frame is freed. This routine updates the page tables * of all the active procs that uses the given frame. It usually clears * the page table entry for the given frame and records the dirty bit * value. * * Params: * fr_id - frame id of the frame being paged out/removed * * Returns: int * TRUE - if the dirty bit is set for at least one proc * FALSE - if the dirty bit is not set for any of the procs * EMPTY - oops! something went wrong.. ******************************************************************************/ int pgt_update_all(int fr_id) { int rc = FALSE; int pid = 0; STATWORD ps; disable(ps); DTRACE_START; if (FALSE == FR_IS_ID_VALID(fr_id)) { DTRACE("DBG$ %d %s> bad fr id %d\n", currpid, __func__, fr_id); rc = EMPTY; goto RESTORE_AND_RETURN; } /* If the given frame is free, the required pgt's would have been updated * earlier. Just return. */ if (FR_FREE == FR_GET_STATUS(fr_id)) { DTRACE("DBG$ %d %s> fr id %d is free\n", \ currpid, __func__, fr_id, FR_GET_STATUS(fr_id)); rc = FALSE; goto RESTORE_AND_RETURN; } /* This routine is only to update the page tables when a frame is removed * or a proc unmaps the frame. So, we only have to bother about data pages. */ if (FR_PAGE != FR_GET_TYPE(fr_id)) { DTRACE("DBG$ %d %s> fr id %d isn't a data frame.. type %d\n", \ currpid, __func__, fr_id, FR_GET_TYPE(fr_id)); rc = FALSE; goto RESTORE_AND_RETURN; } for (pid = 0; pid < NPROC; ++pid) { if (PRFREE == P_GET_PSTATE(pid)) { /* Don't bother if a proc isn't present. */ continue; } if (TRUE == frm_pidmap_oper(fr_id, pid, FR_OP_PMAP_CHK)) { DTRACE("DBG$ %d %s> fr id %d is used by pid %d\n", currpid, __func__, fr_id, pid); rc |= pgt_update_for_pid(fr_id, pid); } } RESTORE_AND_RETURN: DTRACE_END; restore(ps); return rc; }
int vpmem_module_init (int is_client, vpmem_dev_init_t dev_init) { NkPhAddr plink; NkDevVlink* vlink; int err = 0; NkOsId my_id = nkops.nk_id_get(); NkOsId vlink_id; vpmem_dev_t* vpmem; int count = 0; DTRACE("initializing module, my_id %ld\n", (unsigned long)my_id); plink = 0; while ((plink = nkops.nk_vlink_lookup(VPMEM_VLINK_NAME, plink)) != 0) { vlink = nkops.nk_ptov(plink); vlink_id = is_client ? vlink->c_id : vlink->s_id; DTRACE("comparing my_id %d to vlink_id %d (c_id %d, s_id %d)\n", my_id, vlink_id, vlink->c_id, vlink->s_id); if (vlink_id == my_id) { vpmem = vpmem_dev_alloc(); if (!vpmem) { err = -ENOMEM; break; } vpmem->plink = plink; vpmem->vlink = vlink; err = dev_init(vpmem); if (err) { vpmem_dev_free(vpmem); break; } count++; DTRACE("device %s is created for OS#%d<-OS#%d link=%d\n", vpmem->name, vlink->s_id, vlink->c_id, vlink->link); } } DTRACE("module initialized, %u vpmem devices created, err %d\n", count, err); return err; }
static void hw_shm_init_data(device *me) { hw_shm_device *shm = (hw_shm_device*)device_data(me); const device_unit *d; reg_property_spec reg; int i; /* Obtain the Key Value */ if (device_find_property(me, "key") == NULL) error("shm_init_data() required key property is missing\n"); shm->key = (key_t) device_find_integer_property(me, "key"); DTRACE(shm, ("shm key (0x%08x)\n", shm->key) ); /* Figure out where this memory is in address space and how long it is */ if ( !device_find_reg_array_property(me, "reg", 0, ®) ) error("hw_shm_init_data() no address registered\n"); /* Determine the address and length being as paranoid as possible */ shm->physical_address = 0xffffffff; shm->sizeof_memory = 0xffffffff; for ( i=0 ; i<reg.address.nr_cells; i++ ) { if (reg.address.cells[0] == 0 && reg.size.cells[0] == 0) continue; if ( shm->physical_address != 0xffffffff ) device_error(me, "Only single celled address ranges supported\n"); shm->physical_address = reg.address.cells[i]; DTRACE(shm, ("shm physical_address=0x%x\n", shm->physical_address)); shm->sizeof_memory = reg.size.cells[i]; DTRACE(shm, ("shm length=0x%x\n", shm->sizeof_memory)); } if ( shm->physical_address == 0xffffffff ) device_error(me, "Address not specified\n" ); if ( shm->sizeof_memory == 0xffffffff ) device_error(me, "Length not specified\n" ); /* Now actually attach to or create the shared memory area */ shm->id = shmget(shm->key, shm->sizeof_memory, IPC_CREAT | 0660); if (shm->id == -1) error("hw_shm_init_data() shmget failed\n"); shm->shm_address = shmat(shm->id, (char *)0, SHM_RND); if (shm->shm_address == (void *)-1) error("hw_shm_init_data() shmat failed\n"); }
/* Name: l_get_next_writer * * Desc: Gets the next writer to whom the write lock should be awarded. It goes * through the list and makes the proc ready, if any and returns TRUE. If * eligible writers are not available, it just returns FALSE. * * Params: * lid - read lock ID * * Returns: int * TRUE - if eligible writer is available * FLASE - otherwise */ int l_get_next_writer(int lid) { int next_pid = EMPTY;; int nextrw = L_GET_NEXTRW(lid); DTRACE_START; /* Set the lstate based on the next available waiter. */ if (LT_WRITE == nextrw) { DTRACE("DBG$ %d %s> lid %d state changed from %s to Write\n", \ currpid, __func__, currpid, L_GET_LSTATESTR(lid)); L_SET_LSTATE(lid, LS_WRITE); } else if (EMPTY == nextrw) { DTRACE("DBG$ %d %s> lid %d state changed from %s to Free\n", \ currpid, __func__, currpid, L_GET_LSTATESTR(lid)); L_SET_LSTATE(lid, LS_FREE); } else { DTRACE("DBG$ %d %s> bad nextrw %d for lid %d - should have been " \ " WRITE or EMPTY\n", \ currpid, __func__, currpid, lid, next_pid); ASSERT(0); goto RETURN_FALSE; } if (EMPTY == (next_pid = getlast(L_GET_LWTAIL(lid)))) { #ifdef DBG_ON l_print_lock_details(lid); #endif /* DBG_ON */ DTRACE("DBG$ %d %s> bad pid %d in nextq tail %d for lid %d\n", \ currpid, __func__, next_pid, L_GET_NEXTQ(lid), lid); ASSERT(0); goto RETURN_FALSE; } L_DEC_NWWRITE(lid); L_INC_NAWRITE(lid); /* Enqueue the waiting writer in ready queue. */ ready(next_pid, RESCHNO); l_pidmap_oper(lid, next_pid, L_MAP_RELEASE, L_MAP_SET); DTRACE("DBG$ %d %s> lid %d next writer lock for pid %d\n", \ currpid, __func__, lid, next_pid); l_recal_next(lid); DTRACE_END; return TRUE; RETURN_FALSE: DTRACE_END; return FALSE; }
static void hw_sem_init_data(device *me) { hw_sem_device *sem = (hw_sem_device*)device_data(me); const device_unit *d; int status; union semun help; /* initialize the properties of the sem */ if (device_find_property(me, "key") == NULL) error("sem_init_data() required key property is missing\n"); if (device_find_property(me, "value") == NULL) error("sem_init_data() required value property is missing\n"); sem->key = (key_t) device_find_integer_property(me, "key"); DTRACE(sem, ("semaphore key (%d)\n", sem->key) ); sem->initial = (int) device_find_integer_property(me, "value"); DTRACE(sem, ("semaphore initial value (%d)\n", sem->initial) ); d = device_unit_address(me); sem->physical_address = d->cells[ d->nr_cells-1 ]; DTRACE(sem, ("semaphore physical_address=0x%x\n", sem->physical_address)); /* Now to initialize the semaphore */ if ( sem->initial != -1 ) { sem->id = semget(sem->key, 1, IPC_CREAT | 0660); if (sem->id == -1) error("hw_sem_init_data() semget failed\n"); help.val = sem->initial; status = semctl( sem->id, 0, SETVAL, help ); if (status == -1) error("hw_sem_init_data() semctl -- set value failed\n"); } else { sem->id = semget(sem->key, 1, 0660); if (sem->id == -1) error("hw_sem_init_data() semget failed\n"); } sem->count = semctl( sem->id, 0, GETVAL, help ); if (sem->count == -1) error("hw_sem_init_data() semctl -- get value failed\n"); DTRACE(sem, ("semaphore OS value (%d)\n", sem->count) ); }
QObject* QCastPluginFactory::create (const QString &mimeType, const QUrl& url, const QStringList& argumentNames, const QStringList& argumentValues) const { try { DTRACE("QCastPluginFactory::create " << mimeType.toStdString()); if (mimeType == "application/cast-displayview") { QViewContainer* pPlug = new QViewContainer(); DMESSAGE("QViewContainer created"); if (m_pModel) { QString viewName = url.path().mid(1); // "cogxdisp://view/<path>" DMESSAGE("View to show " << viewName.toStdString()); auto it = m_pModel->m_Views.find(viewName.toStdString()); if (! (it == m_pModel->m_Views.end())) { pPlug->setView(m_pModel, it->second); DMESSAGE("setView applied: " << it->second->m_id); } } return pPlug; } } catch (...) { DMESSAGE("MISERABLY FAILED"); } return NULL; }
bool OverlayPlaneBase::assignToDevice(int disp) { uint32_t pipeConfig = 0; RETURN_FALSE_IF_NOT_INIT(); VTRACE("overlay %d assigned to disp %d", mIndex, disp); switch (disp) { case IDisplayDevice::DEVICE_EXTERNAL: pipeConfig = (0x2 << 6); break; case IDisplayDevice::DEVICE_PRIMARY: default: pipeConfig = 0; break; } // if pipe switching happened, then disable overlay first if (mPipeConfig != pipeConfig) { DTRACE("overlay %d switched from %d to %d", mIndex, mDevice, disp); disable(); } mPipeConfig = pipeConfig; DisplayPlane::assignToDevice(disp); enable(); return true; }
int vrpc_server_open (vrpc_t* vrpc, vrpc_call_t call, void* cookie, int direct) { vrpc->call = call; vrpc->cookie = cookie; if (direct) { vrpc->wrapper = _vrpc_direct_call; vrpc->thread = 0; } else { vrpc->open = 1; /* Thread will terminate otherwise */ vrpc->wrapper = _vrpc_indirect_call; vrpc->thread = kthread_run(_vrpc_server_thread, vrpc, "vrpc-server"); if (!vrpc->thread) { return -EFAULT; } } vrpc->open = 1; _vrpc_handshake(vrpc); DTRACE("VLINK %d (%d -> %d) [%s] server open\n", vrpc->vlink->link, vrpc->vlink->c_id, vrpc->vlink->s_id, (vrpc->my.info ? vrpc->my.info : "")); return 0; }
/* Name: l_clear_pidmaps * * Desc: Clears all the entries corresponding to the pid in all available * lid's pidmaps. This is usually called when a process is killed. * * Params: * pid - process ID of the process whose pid-bit is to be cleared * * Returns: int * OK - on success * SYSERR - on error */ int l_clear_pidmaps(int pid) { int lid = EMPTY; STATWORD ps; disable(ps); DTRACE_START; if (isbadpid(pid)) { DTRACE("DBG$ %d %s> bad pid %d\n", currpid, __func__, pid); goto RETURN_ERROR; } /* Go thru all the locks and clear the pid-bit on all the pidmaps. */ for (lid = 0; lid < NLOCKS; ++lid) { l_pidmap_oper(lid, pid, L_MAP_DELETE, L_MAP_CLR); l_pidmap_oper(lid, pid, L_MAP_RELEASE, L_MAP_CLR); l_pidmap_oper(lid, pid, L_MAP_LOG, L_MAP_CLR); } DTRACE_END; restore(ps); return OK; RETURN_ERROR: DTRACE_END; restore(ps); return SYSERR; }
int vrpc_client_open (vrpc_t* vrpc, vrpc_ready_t ready, void* cookie) { vrpc->ready = ready; vrpc->cookie = cookie; vrpc->wrapper = _vrpc_wakeup; if (ready) { if (!kthread_run(_vrpc_client_thread, vrpc, "vrpc-client")) { return -EFAULT; } } else { if (!_vrpc_wait_for_peer(vrpc)) { return -EFAULT; } } vrpc->open = 1; DTRACE("VLINK %d (%d -> %d) [%s] client open\n", vrpc->vlink->link, vrpc->vlink->c_id, vrpc->vlink->s_id, (vrpc->my.info ? vrpc->my.info : "")); return 0; }
static unsigned hw_disk_io_read_buffer(device *me, void *dest, int space, unsigned_word addr, unsigned nr_bytes, cpu *processor, unsigned_word cia) { hw_disk_device *disk = device_data(me); unsigned nr_bytes_read; if (space != 0) device_error(me, "read - extended disk addressing unimplemented"); if (nr_bytes == 0) nr_bytes_read = 0; else if (fseek(disk->image, addr, SEEK_SET) < 0) nr_bytes_read = 0; else if (fread(dest, nr_bytes, 1, disk->image) != 1) nr_bytes_read = 0; else nr_bytes_read = nr_bytes; DTRACE(disk, ("io-read - address 0x%lx, nr-bytes-read %d, requested %d\n", (unsigned long) addr, (int)nr_bytes_read, (int)nr_bytes)); return nr_bytes_read; }
/******************************************************************************* * Name: remove_pgd * * Desc: Removes the pgd of a proc and frees the frame. * * Params: * pid - pid whose pgd has to be removed * * Returns: Nothing. ******************************************************************************/ void remove_pgd(int pid) { int pgd_fr_id = EMPTY; STATWORD ps; disable(ps); DTRACE_START; if (isbadpid(pid) || (PRFREE == P_GET_PSTATE(pid))) { DTRACE("DBG$ %d %s> bad pid %d or bad state %d\n", \ currpid, __func__, pid, P_GET_PSTATE(pid)); goto RESTORE_AND_RETURN; } /* Each process has a pdir whose base addr is stored in pgdir field of * the PCB. This is hosted on a frame and we need to free that frame as the * process is being killed. */ pgd_fr_id = FR_PA_TO_ID(P_GET_PDIR(pid)); free_frm(pgd_fr_id); RESTORE_AND_RETURN: DTRACE_END; restore(ps); return; }
void UeventObserver::onUevent() { char *msg = mUeventMessage; const char *envelope = DrmConfig::getUeventEnvelope(); if (strncmp(msg, envelope, strlen(envelope)) != 0) return; msg += strlen(msg) + 1; UeventListener *listener; String8 key; while (*msg) { key = String8(msg); if (mListeners.indexOfKey(key) >= 0) { DTRACE("received Uevent: %s", msg); listener = mListeners.valueFor(key); if (listener) { listener->func(listener->data); } else { ETRACE("no listener for uevent %s", msg); } } msg += strlen(msg) + 1; } }
static unsigned hw_disk_io_write_buffer(device *me, const void *source, int space, unsigned_word addr, unsigned nr_bytes, cpu *processor, unsigned_word cia) { hw_disk_device *disk = device_data(me); unsigned nr_bytes_written; if (space != 0) device_error(me, "write - extended disk addressing unimplemented"); if (disk->read_only) nr_bytes_written = 0; else if (nr_bytes == 0) nr_bytes_written = 0; else if (fseek(disk->image, addr, SEEK_SET) < 0) nr_bytes_written = 0; else if (fwrite(source, nr_bytes, 1, disk->image) != 1) nr_bytes_written = 0; else nr_bytes_written = nr_bytes; DTRACE(disk, ("io-write - address 0x%lx, nr-bytes-written %d, requested %d\n", (unsigned long) addr, (int)nr_bytes_written, (int)nr_bytes)); return nr_bytes_written; }
static void start_programming_byte(device *me, hw_eeprom_device *eeprom, unsigned_word address, unsigned8 new_byte) { unsigned8 old_byte = eeprom->memory[address]; DTRACE(eeprom, ("start-programing-byte - address 0x%lx, new 0x%lx, old 0x%lx\n", (unsigned long)address, (unsigned long)new_byte, (unsigned long)old_byte)); eeprom->byte_program_address = address; /* : old new : ~old : new&~old : 0 0 : 1 : 0 : 0 1 : 1 : 1 -- can not set a bit : 1 0 : 0 : 0 : 1 1 : 0 : 0 */ if (~old_byte & new_byte) invalid_write(me, eeprom->state, address, new_byte, "setting cleared bit"); /* : old new : old&new : 0 0 : 0 : 0 1 : 0 : 1 0 : 0 : 1 1 : 1 */ eeprom->byte_program_byte = new_byte & old_byte; eeprom->memory[address] = ~new_byte & ~0x24; /* LE-bits 5:3 zero */ eeprom->program_start_time = device_event_queue_time(me); eeprom->program_finish_time = (eeprom->program_start_time + eeprom->byte_write_delay); }
/******************************************************************************* * Name: new_pgd * * Desc: Allocates and intializes a new page directory. Usually called during * process creation. * * Params: None. * * Returns: Pointer to the newly allocated pgd. NULL on error. ******************************************************************************/ pd_t * new_pgd(void) { int pd_id = 0; pd_t *new_pd = NULL; frm_map_t *new_frame = NULL; STATWORD ps; disable(ps); DTRACE_START; new_frame = get_frm(FR_PDIR); if (NULL == new_frame) { DTRACE("DBG$ %d %s> get_frm() failed\n", currpid, __func__); goto RESTORE_AND_RETURN_NULL; } new_frame->fr_type = FR_PDIR; /* The PD would start at the PA of the frame that we just got. */ new_pd = (pd_t *) FR_ID_TO_PA(new_frame->fr_id); /* Same as page tables, each pd entry is 4 bytes long. Thus, a frame which * is 4 KB, can hold (NBPG / 4 = 1024) entries. Intially all the fields * are set to zero. Also, every process will share the global page tables. */ bzero(new_pd, sizeof(pd_t)); for (pd_id = 0; pd_id < PT_NGPT; ++pd_id) { new_pd[pd_id].pd_pres = 1; new_pd[pd_id].pd_write = 1; new_pd[pd_id].pd_avail = 1; /* The base should contain vpage of the frame containing the global * page tables. */ new_pd[pd_id].pd_base = VADDR_TO_VPAGE((unsigned) g_pt[pd_id]); } DTRACE("DBG$ %d %s> pgd at 0x%08x is being returned\n", \ currpid, __func__, new_pd); DTRACE_END; restore(ps); return new_pd; RESTORE_AND_RETURN_NULL: DTRACE_END; restore(ps); return NULL; }
static void vaudio_sysconf_trigger (NkVaudio dev) { DTRACE ("Sending sysconf OS#%d(%d)->OS#%d(%d)\n", dev->vlink->c_id, dev->vlink->c_state, dev->vlink->s_id, dev->vlink->s_state); nkops.nk_xirq_trigger(NK_XIRQ_SYSCONF, dev->vlink->s_id); }
void AST_PrintCommand(AST_Command_t *command) { int i; for (i = 0; i < command->argc; i++) { DTRACE("%s ", command->argv[i]->str); } if (command->in) { DTRACE("< %s ", command->in->file->str); } if (command->out) { DTRACE("> %s ", command->out->file->str); } if (command->background) { DTRACE("&"); } }
static void finish_erasing_chip(device *me, hw_eeprom_device *eeprom) { DTRACE(eeprom, ("finish-erasing-chip\n")); memset(eeprom->memory, 0xff, eeprom->sizeof_memory); dump_eeprom(me, eeprom); }
static vpmem_dev_t* vpmem_dev_lookup_by_name (char* name) { vpmem_dev_t* vpmem = vpmem_dev_head; while (vpmem && strcmp(vpmem->name, name)) { vpmem = vpmem->next; } if (vpmem) { DTRACE("vpmem %s: [0x%x..0x%x]\n", name, vpmem->pmem_phys, vpmem->pmem_phys + vpmem->pmem_size); } else { DTRACE("vpmem %s not found\n", name); } return vpmem; }