static int libInit(LIBBASETYPEPTR nh) { KPRINTF(10, ("libInit nh: 0x%08lx SysBase: 0x%08lx\n", nh, SysBase)); nh->nh_UtilityBase = OpenLibrary("utility.library", 39); #define UtilityBase nh->nh_UtilityBase if(UtilityBase) { struct NepClassHid *nch; NewList(&nh->nh_Bindings); nch = &nh->nh_DummyNCH; nch->nch_ClsBase = nh; nch->nch_Interface = NULL; nch->nch_CDC = AllocVec(sizeof(struct ClsDevCfg), MEMF_PUBLIC|MEMF_CLEAR); if(!nch->nch_CDC) { return FALSE; } } else { KPRINTF(20, ("libInit: OpenLibrary(\"utility.library\", 39) failed!\n")); return FALSE; } KPRINTF(10, ("libInit: Ok\n")); return TRUE; }
/* *=========================================================== * devOpen(ioreq, unit, flags, base) *=========================================================== * * This is the the DEV_OPEN function. * */ static int devOpen(LIBBASETYPEPTR base, struct IOUsbHWReq *ioreq, ULONG unit, ULONG flags) { KPRINTF(10, ("devOpen ioreq: 0x%p unit: %ld flags: 0x%08lx base: 0x%p\n", ioreq, unit, flags, base)); KPRINTF(10, ("devOpen: openCnt = %ld\n", base->hd_Library.lib_OpenCnt)); if(ioreq->iouh_Req.io_Message.mn_Length < sizeof(struct IOUsbHWReq)) { KPRINTF(20, ("devOpen: invalid MN_LENGTH!\n")); ioreq->iouh_Req.io_Error = IOERR_BADLENGTH; } else { /* Default to open failure. */ ioreq->iouh_Req.io_Error = IOERR_OPENFAIL; ioreq->iouh_Req.io_Unit = Open_Unit(ioreq, unit, base); if(!ioreq->iouh_Req.io_Unit) { KPRINTF(20, ("devOpen: could not open unit!\n")); } else { /* Opended ok! */ ioreq->iouh_Req.io_Message.mn_Node.ln_Type = NT_REPLYMSG; ioreq->iouh_Req.io_Error = 0; return TRUE; } } return FALSE; }
void PrintException (struct ContextState *es, char *str, int panic) { int privilege; privilege = es->return_cs & 0x03; if (privilege != 0) { KPRINTF("return_ss = %#010x return_esp = %#010x", es->return_ss, es->return_esp); } KPRINTF("return_eflags = %#010x cr2 = %#010x", es->return_eflags, GetCR2()); KPRINTF("return_cs = %#010x return_eip = %#010x", es->return_cs, es->return_eip); KPRINTF("error_code = %#010x exception = %#010x", es->error_code, es->exception); KPRINTF("EAX = %#010x ECX = %#010x", es->eax, es->ecx); KPRINTF("EDX = %#010x EBX = %#010x", es->edx, es->ebx); KPRINTF("EBP = %#010x ", es->ebp); KPRINTF("ESI = %#010x EDI = %#010x", es->esi, es->edi); KPRINTF ("EXCEPTION = %d #%s name = %s", es->exception, exception_string[es->exception % 32], current_process->exe_name); KPRINTF ("pid = %d, Name = %s", current_process->pid, current_process->exe_name); if (panic == TRUE) KPANIC (str); }
static int libExpunge(LIBBASETYPEPTR nh) { struct NepClassSerial *ncp; KPRINTF(10, ("libExpunge nh: 0x%08lx\n", nh)); if(nh->nh_DevBase->np_Library.lib_OpenCnt == 1) { KPRINTF(1, ("libExpunge: closelibrary utilitybase 0x%08lx\n", UtilityBase)); CloseLibrary((struct Library *) UtilityBase); ncp = (struct NepClassSerial *) nh->nh_Units.lh_Head; while(ncp->ncp_Unit.unit_MsgPort.mp_Node.ln_Succ) { Remove((struct Node *) ncp); FreeVec(ncp); ncp = (struct NepClassSerial *) nh->nh_Units.lh_Head; } nh->nh_DevBase->np_Library.lib_OpenCnt--; RemDevice((struct Device *) nh->nh_DevBase); KPRINTF(5, ("libExpunge: Unloading done! palmpda.class expunged!\n\n")); } else { KPRINTF(5, ("libExpunge: Could not expunge, LIBF_DELEXP set!\n")); return(FALSE); } return(TRUE); }
AROS_UFH3(DEVBASETYPEPTR, devInit, AROS_UFHA(DEVBASETYPEPTR, base, D0), AROS_UFHA(BPTR, seglist, A0), AROS_UFHA(struct ExecBase *, SysBase, A6)) { AROS_USERFUNC_INIT KPRINTF(10, ("devInit base: 0x%08lx seglist: 0x%08lx SysBase: 0x%08lx\n", base, seglist, SysBase)); base->np_Library.lib_Node.ln_Type = NT_DEVICE; base->np_Library.lib_Node.ln_Name = DEVNAME; base->np_Library.lib_Flags = LIBF_SUMUSED|LIBF_CHANGED; base->np_Library.lib_Version = VERSION_NUMBER; base->np_Library.lib_Revision = REVISION_NUMBER; base->np_Library.lib_IdString = VERSION_STRING; /* Store segment */ base->np_SegList = seglist; if((base->np_UtilityBase = OpenLibrary("utility.library", 0))) { KPRINTF(10, ("devInit: Ok\n")); KPRINTF(10, ("devInit: openCnt = %ld\n", base->np_Library.lib_OpenCnt)); return(base); } else { return(NULL); } return(base); AROS_USERFUNC_EXIT }
/** * Sends a NetSync packet. * * @param socket Connection socket * @param buffer Buffer to be transmitted * @param length Buffer length * @param type Packet type * @return Number of bytes written, or -1: error */ __saveds __asm LONG PL_NetSyncWrite ( register __a0 APTR socket, register __a1 APTR buffer, register __d0 LONG length, register __d1 UWORD type ) { struct PL_Socket *sock = (struct PL_Socket *)socket; struct PL_NetSync_Header netsyncp; // NetSync header LONG rlen = -1; KPRINTF(10, ("NetSyncWrite\n")); sock->lastError = PLERR_OKAY; /* Create transaction ID */ if(!sock->initiator) { sock->transactionID++; if((sock->transactionID==0x00) || (sock->transactionID==0xFF)) // wrap around in time sock->transactionID=0x01; } /* create NetSync header */ netsyncp.type = 0x01;//type; netsyncp.transID = sock->transactionID; netsyncp.dataSize = length; #ifdef NETSYNCDEBUG Printf("NetSync A->P: type=%ld size=%ld tID=0x%02lx\n", netsyncp.type, netsyncp.dataSize, netsyncp.transID); #endif KPRINTF(10, ("NetSync A->P: type=%ld size=%ld tID=0x%02lx\n", netsyncp.type, netsyncp.dataSize, netsyncp.transID)); if(PL_RawWrite(socket, (UBYTE *) &netsyncp, sizeof(netsyncp)) == sizeof(netsyncp)) { #ifdef NETSYNCDEBUG Printf("NetSync data...\n", netsyncp.type, netsyncp.dataSize, netsyncp.transID); #endif KPRINTF(10, ("NetSync data...\n", netsyncp.type, netsyncp.dataSize, netsyncp.transID)); rlen = PL_RawWrite(socket, buffer, length); if(rlen != length) { #ifdef NETSYNCDEBUG Printf("Write error %ld != %ld\n", rlen, length); #endif KPRINTF(10, ("Write error %ld != %ld\n", rlen, length)); return(-1); } } return(rlen); }
int Fork (void) { struct Process *newproc; KPRINTF ("Fork()"); if ((newproc = AllocProcess(PROC_TYPE_USER)) != NULL) { StrLCpy (newproc->exe_name, current_process->exe_name, PROC_NAME_SZ); if (*newproc->exe_name == '\0') { KPRINTF ("Fork() exe_name == 0"); while(1) KWait(0); } if (DuplicateAddressSpace (¤t_process->as, &newproc->as) == 0) { newproc->user_as = &newproc->as; if (0 == FSCreateProcess (current_process, newproc, current_process->current_dir, DUP_FD)) { USigFork (current_process, newproc); if (ArchInitFork (newproc) == 0) { DisableInterrupts(); newproc->state = PROC_STATE_READY; newproc->priority = 0; SchedReady (newproc); Reschedule(); EnableInterrupts(); return newproc->pid; } FSExitProcess (newproc); } FreeAddressSpace (&newproc->as); } FreeProcess (newproc); } return -1; }
int CreateAddressSpace (struct AddressSpace *as) { struct MemRegion *mr; KPRINTF ("CreateAddressSpace()"); MutexLock (&vm_mutex); if (PmapInit(as) == TRUE) { LIST_INIT (&as->sorted_memregion_list); LIST_INIT (&as->free_memregion_list); as->hint = NULL; as->page_cnt = 0; if ((mr = LIST_HEAD (&unused_memregion_list)) != NULL) { LIST_REM_HEAD (&unused_memregion_list, unused_entry); LIST_ADD_HEAD (&as->free_memregion_list, mr, free_entry); LIST_ADD_HEAD (&as->sorted_memregion_list, mr, sorted_entry); free_memregion_cnt --; LIST_INIT (&mr->pageframe_list); mr->as = as; mr->type = MR_TYPE_FREE; mr->prot = VM_PROT_NONE; mr->flags = MR_FLAGS_NONE; mr->base_addr = VM_USER_BASE; mr->ceiling_addr = VM_USER_CEILING; as->active = TRUE; MutexUnlock (&vm_mutex); return 0; } PmapDestroy(as); } as->active = FALSE; KPRINTF ("Failed to allocate address-space"); MutexUnlock (&vm_mutex); return -1; }
static int devInit(LIBBASETYPEPTR base) { KPRINTF(10, ("devInit base: 0x%p SysBase: 0x%p\n", base, SysBase)); base->hd_MemPool = CreatePool(MEMF_PUBLIC | MEMF_CLEAR | MEMF_SEM_PROTECTED, 16384, 4096); if(base->hd_MemPool) { NEWLIST(&base->hd_Units); KPRINTF(10, ("devInit: Ok\n")); } else { KPRINTF(10, ("devInit: CreatePool() failed!\n")); return FALSE; } KPRINTF(10, ("devInit: openCnt = %ld\n", base->hd_Library.lib_OpenCnt)); return TRUE; }
/* /// "usbAttemptDeviceBinding()" */ struct NepClassSerial * usbAttemptDeviceBinding(struct NepSerialBase *nh, struct PsdDevice *pd) { struct Library *ps; struct AutoBindData *abd = ClassBinds; IPTR prodid; IPTR vendid; KPRINTF(1, ("nepSerialAttemptDeviceBinding(%08lx)\n", pd)); if((ps = OpenLibrary("poseidon.library", 4))) { psdGetAttrs(PGA_DEVICE, pd, DA_VendorID, &vendid, DA_ProductID, &prodid, TAG_END); CloseLibrary(ps); while(abd->abd_VendID) { if((vendid == abd->abd_VendID) && (prodid == abd->abd_ProdID)) { return(usbForceDeviceBinding(nh, pd)); } abd++; } } return(NULL); }
/* /// "usbReleaseDeviceBinding()" */ void usbReleaseDeviceBinding(struct NepSerialBase *nh, struct NepClassSerial *ncp) { struct Library *ps; STRPTR devname; KPRINTF(1, ("nepSerialReleaseDeviceBinding(%08lx)\n", ncp)); if((ps = OpenLibrary("poseidon.library", 4))) { Forbid(); ncp->ncp_ReadySignal = SIGB_SINGLE; ncp->ncp_ReadySigTask = FindTask(NULL); if(ncp->ncp_Task) { Signal(ncp->ncp_Task, SIGBREAKF_CTRL_C); } Permit(); while(ncp->ncp_Task) { Wait(1L<<ncp->ncp_ReadySignal); } //FreeSignal(ncp->ncp_ReadySignal); psdGetAttrs(PGA_DEVICE, ncp->ncp_Device, DA_ProductName, &devname, TAG_END); psdAddErrorMsg(RETURN_OK, (STRPTR) libname, "'%s' annealed and broke off.", devname); /*psdFreeVec(ncp);*/ CloseLibrary(ps); } }
static int libExpunge(LIBBASETYPEPTR nh) { KPRINTF(10, ("libExpunge nh: 0x%08lx SysBase: 0x%08lx\n", nh, SysBase)); CloseLibrary(UtilityBase); FreeVec(nh->nh_DummyNCH.nch_CDC); return TRUE; }
/* /// "usbReleaseInterfaceBinding()" */ void usbReleaseInterfaceBinding(struct NepHidBase *nh, struct NepClassHid *nch) { struct Library *ps; struct PsdConfig *pc; struct PsdDevice *pd; STRPTR devname; KPRINTF(1, ("nepHidReleaseInterfaceBinding(%08lx)\n", nch)); if((ps = OpenLibrary("poseidon.library", 4))) { Forbid(); Remove(&nch->nch_Node); nch->nch_ReadySignal = SIGB_SINGLE; nch->nch_ReadySigTask = FindTask(NULL); if(nch->nch_Task) { Signal(nch->nch_Task, SIGBREAKF_CTRL_C); } Permit(); while(nch->nch_Task) { Wait(1L<<nch->nch_ReadySignal); } //FreeSignal(nch->nch_ReadySignal); psdGetAttrs(PGA_INTERFACE, nch->nch_Interface, IFA_Config, &pc, TAG_END); psdGetAttrs(PGA_CONFIG, pc, CA_Device, &pd, TAG_END); psdGetAttrs(PGA_DEVICE, pd, DA_ProductName, &devname, TAG_END); psdAddErrorMsg(RETURN_OK, (STRPTR) libname, "'%s' fell silent!", devname); psdFreeVec(nch); CloseLibrary(ps); } }
int CreatePathInfo (struct PathInfo *pi, char *pathname, bool keep_canon) { pi->buffer = NULL; pi->canon = NULL; if ((pi->canon = CanonPathname(pathname)) != NULL) { if ((pi->buffer = TranslatePathnameAliases (pi->canon)) != NULL) { if (InitPathInfo (pi) == 0) { KPRINTF ("pi->canon = %s", pi->canon); if (keep_canon != KEEP_CANON) { KFree (pi->canon); pi->canon = NULL; } return 0; } KFree (pi->buffer); } KFree (pi->canon); } SetError (ENOENT); return -1; }
void *cd_expunge (void) { KPRINTF ("cd_expunge()"); RemDevice (&cd_device); return elf_header; }
int CopyArgEnvToUserSpace (struct ArgInfo *ai, struct AddressSpace *new_as) { vm_addr ubase; char **argv, **env; KPRINTF ("CopyArgsToUserSpace()"); if ((ubase = UMap(0, ARG_MAX ,VM_PROT_READWRITE, 0)) != MAP_FAILED) { argv = ai->argv; env = ai->env; if (argv != NULL) { while (*argv != NULL) { *argv = (char *)ubase + ((char *)*argv - (char *)ai->buf); argv++; } } if (env != NULL) { while (*env != NULL) { *env = (char *)ubase + ((char *)*env - (char *)ai->buf); env++; } } ai->ubase = ubase; ai->uargv = (char **)((uint8 *)ubase + ((uint8 *)ai->argv - (uint8 *)ai->buf)); ai->uenv = (char **)((uint8 *)ubase + ((uint8 *)ai->env - (uint8 *)ai->buf)); KPRINTF ("CopyOut() CopyArgsToUserSpace"); if (CopyOut (new_as, (void *)ubase, ai->buf, ARG_MAX) == 0) { return 0; } UUnmap (ubase); } return -1; }
void DoAtaMediaPresent (struct BlkReq *blkreq) { struct BlockDeviceStat *stat; struct Ata *ata; KPRINTF ("DoAtaMediaPresent()"); stat = blkreq->stat; ata = blkreq->unitp; if (ata->config == ATA_CONFIG_ATA) { stat->total_sectors = ata->size; stat->media_state = MEDIA_INSERTED; stat->write_protect = FALSE; blkreq->error = 0; blkreq->rc = 0; } else if (ata->config == ATA_CONFIG_ATAPI) { if (AtapiMediaPresent (ata) == ATA_MEDIA_PRESENT) { KPRINTF ("MEDIA_PRESENT"); stat->total_sectors = 0; stat->media_state = MEDIA_INSERTED; stat->write_protect = TRUE; } else { KPRINTF ("MEDIA_REMOVED"); stat->total_sectors = 0; stat->media_state = MEDIA_REMOVED; stat->write_protect = TRUE; } blkreq->error = 0; blkreq->rc = 0; } else { blkreq->error = EIO; blkreq->rc = -1; } }
int cd_init (void *elf) { KPRINTF ("cd_init()"); elf_header = elf; AddDevice (&cd_device); return 0; }
static int devClose(LIBBASETYPEPTR base, struct IOUsbHWReq *ioreq) { KPRINTF(10, ("devClose ioreq: 0x%p base: 0x%p\n", ioreq, base)); Close_Unit(base, (struct PCIUnit *) ioreq->iouh_Req.io_Unit, ioreq); ioreq->iouh_Req.io_Unit = (APTR) -1; ioreq->iouh_Req.io_Device = (APTR) -1; return TRUE; }
int FatEraseDisk (struct FatSB *fsb, uint32 flags) { uint32 t, sectors; uint32 fat_sz; uint32 root_dir_sectors = 0; uint8 temp_sector[512]; KPRINTF ("FatEraseDisk()"); MemSet (temp_sector, 0, 512); if (fsb->fat_type == TYPE_FAT32) fat_sz = fsb->bpb32.sectors_per_fat32; else fat_sz = fsb->bpb.sectors_per_fat16; root_dir_sectors = ((fsb->bpb.root_entries_cnt * 32) + (fsb->bpb.bytes_per_sector - 1)) / fsb->bpb.bytes_per_sector; if (flags & FORMATF_QUICK) { sectors = fsb->bpb.reserved_sectors_cnt + (fsb->bpb.fat_cnt * fat_sz) + root_dir_sectors; if (fsb->fat_type == TYPE_FAT32) sectors += fsb->bpb.sectors_per_cluster; } else sectors = fsb->partition_size; for (t=0; t<sectors; t++) { KPRINTF ("Erasing sector %d", t); WriteBlocks (fsb, &kernel_as, temp_sector, t, 0, 512, BUF_IMMED); } return 0; }
/** * Performs the NetSync server ritual. * * @param socket Connection socket * @return success */ BOOL PL_NetSyncServerRitual(struct PL_Socket *socket) { APTR tmpbuf; KPRINTF(10, ("NetSyncServerRitual\n")); tmpbuf = AllocVec(128, MEMF_CLEAR|MEMF_PUBLIC); if(!tmpbuf) { KPRINTF(10, ("NoMem\n")); return(FALSE); } #ifdef NETSYNCDEBUG Printf("NetSync Server Ritual\n"); #endif socket->initiator = FALSE; #if 0 socket->transactionID = 0xff; if(PL_NetSyncRead(socket, tmpbuf, 128) < 0) /* initial packet */ { KPRINTF(10, ("Ritual 1 failed\n")); FreeVec(tmpbuf); return(FALSE); } #endif socket->transactionID = 0x01; if(PL_NetSyncWrite(socket, ritual_stmt2, sizeof(ritual_stmt2), PLPADP_DATA) < 0) /* ritual statement 2 */ { KPRINTF(10, ("Ritual 2 failed\n")); FreeVec(tmpbuf); return(FALSE); } if(PL_NetSyncRead(socket, tmpbuf, 128) < 0) /* ritual response 2 */ { KPRINTF(10, ("Ritual 3 failed\n")); FreeVec(tmpbuf); return(FALSE); } if(PL_NetSyncWrite(socket, ritual_stmt3, sizeof(ritual_stmt3), PLPADP_DATA) < 0) /* ritual statement 3 */ { KPRINTF(10, ("Ritual 4 failed\n")); FreeVec(tmpbuf); return(FALSE); } if(PL_NetSyncRead(socket, tmpbuf, 128) < 0) /* ritual response 3 */ { KPRINTF(10, ("Ritual 5 failed\n")); FreeVec(tmpbuf); return(FALSE); } KPRINTF(10, ("Ritual successful\n")); FreeVec(tmpbuf); return(TRUE); }
static int libInit(LIBBASETYPEPTR nh) { struct NepSerialBase *ret = NULL; KPRINTF(10, ("libInit nh: 0x%08lx SysBase: 0x%08lx\n", nh, SysBase)); nh->nh_UtilityBase = OpenLibrary("utility.library", 39); #define UtilityBase nh->nh_UtilityBase if(UtilityBase) { NewList(&nh->nh_Units); if((nh->nh_DevBase = (struct NepSerDevBase *) MakeLibrary((APTR) DevFuncTable, NULL, (APTR) devInit, sizeof(struct NepSerDevBase), NULL))) { nh->nh_DevBase->np_ClsBase = nh; /*NewList(&nh->nh_DummyUnit.unit_MsgPort.mp_MsgList); nh->nh_DummyUnit.unit_MsgPort.mp_SigBit = 0; nh->nh_DummyUnit.unit_MsgPort.mp_SigTask = NULL; nh->nh_DummyUnit.unit_MsgPort.mp_Node.ln_Type = NT_MSGPORT; nh->nh_DummyUnit.unit_MsgPort.mp_Flags = PA_IGNORE;*/ Forbid(); AddDevice((struct Device *) nh->nh_DevBase); nh->nh_DevBase->np_Library.lib_OpenCnt++; Permit(); ret = nh; } else { KPRINTF(20, ("failed to create palmpda.device\n")); } if(!ret) { CloseLibrary(UtilityBase); } } else { KPRINTF(20, ("libInit: OpenLibrary(\"utility.library\", 39) failed!\n")); } KPRINTF(10, ("libInit: Ok\n")); return(ret ? TRUE : FALSE); }
int cd_closedevice (void *ioreq) { struct FSReq *fsreq = ioreq; struct BlkReq blkreq; struct CDSB *cdsb; KPRINTF ("cd_closedevice()"); cdsb = fsreq->unitp; RWWriteLock (&mountlist_rwlock); if (cdsb->reference_cnt == 0) { KSignal (cdsb->pid, SIG_TERM); WaitPid (cdsb->pid, NULL, 0); blkreq.device = cdsb->device; blkreq.unitp = cdsb->unitp; CloseDevice (&blkreq); cd_device.reference_cnt --; RemMount (cdsb->device_mount); FreeBuf (cdsb->buf); KFree (cdsb); fsreq->error = 0; fsreq->rc = 0; } else { fsreq->error = EBUSY; fsreq->rc = -1; } RWUnlock (&mountlist_rwlock); KPRINTF ("cd_closedevice() +"); return 0; }
int InitIOManager (void) { KPRINTF ("iomanager_init()"); if (KSpawn (IOManagerTask, NULL, 20, "iomanager_task") != -1) { KWait (SIGF_INIT); return 0; } else return -1; }
void DoubleFaultHandler (void) { KPRINTF("return_cs = %#010x return_eip = %#010x", tss.cs, tss.eip); KPRINTF("return_ss = %#010x return_esp = %#010x", tss.ss, tss.esp); KPRINTF("return_eflags = %#010x", tss.eflags); KPRINTF("EAX = %#010x ECX = %#010x", tss.eax, tss.ecx); KPRINTF("EDX = %#010x EBX = %#010x", tss.edx, tss.ebx); KPRINTF("EBP = %#010x ", tss.ebp); KPRINTF("ESI = %#010x EDI = %#010x", tss.esi, tss.edi); KPRINTF ("EXCEPTION : DOUBLE FAULT"); KPanic(); while (1); }
int FatWriteBootRecord (struct FatSB *fsb) { uint8 temp_sector[512]; uint16 signature; int t; KPRINTF ("FatWriteBootRecord()"); ReadBlocks (fsb, &kernel_as, temp_sector, 0, 0, 512); MemCpy (temp_sector, &fsb->bpb, sizeof (struct FatBPB)); if (fsb->fat_type == TYPE_FAT32) { MemCpy (temp_sector + BPB_EXT_OFFSET, &fsb->bpb32, sizeof (struct FatBPB_32Ext)); MemCpy (temp_sector + FAT32_BOOTCODE_START, fat32_bootcode, SIZEOF_FAT32_BOOTCODE); } else { MemCpy (temp_sector + BPB_EXT_OFFSET, &fsb->bpb16, sizeof (struct FatBPB_16Ext)); MemCpy (temp_sector + FAT16_BOOTCODE_START, fat16_bootcode, SIZEOF_FAT16_BOOTCODE); } *(temp_sector + 510) = 0x55; *(temp_sector + 511) = 0xaa; WriteBlocks (fsb, &kernel_as, temp_sector, 0, 0, 512, BUF_IMMED); if (fsb->fat_type == TYPE_FAT32) { WriteBlocks (fsb, &kernel_as, &fsb->fsi, 1, 0, sizeof (struct FatFSInfo), BUF_IMMED); signature = 0xaa55; WriteBlocks (fsb, &kernel_as, &signature, 2, 510, 2, BUF_IMMED); for (t=0; t<3; t++) { ReadBlocks (fsb, &kernel_as, temp_sector, t, 0, 512); WriteBlocks (fsb, &kernel_as, temp_sector, 6+t, 0, 512, BUF_IMMED); } } return 0; }
/* /// "usbForceInterfaceBinding()" */ struct NepClassHid * usbForceInterfaceBinding(struct NepHidBase *nh, struct PsdInterface *pif) { struct Library *ps; struct NepClassHid *nch; struct PsdConfig *pc; struct PsdDevice *pd; STRPTR devname; UBYTE buf[64]; struct Task *tmptask; KPRINTF(1, ("nepHidAttemptInterfaceBinding(%08lx)\n", pif)); if((ps = OpenLibrary("poseidon.library", 4))) { if((nch = psdAllocVec(sizeof(struct NepClassHid)))) { nch->nch_ClsBase = nh; nch->nch_Device = NULL; nch->nch_Interface = pif; nLoadClassConfig(nh); psdSafeRawDoFmt(buf, 64, "simplemidi.class<%08lx>", nch); nch->nch_ReadySignal = SIGB_SINGLE; nch->nch_ReadySigTask = FindTask(NULL); SetSignal(0, SIGF_SINGLE); if((tmptask = psdSpawnSubTask(buf, nHidTask, nch))) { psdBorrowLocksWait(tmptask, 1UL<<nch->nch_ReadySignal); if(nch->nch_Task) { nch->nch_ReadySigTask = NULL; //FreeSignal(nch->nch_ReadySignal); psdGetAttrs(PGA_INTERFACE, pif, IFA_Config, &pc, TAG_END); psdGetAttrs(PGA_CONFIG, pc, CA_Device, &pd, TAG_END); psdGetAttrs(PGA_DEVICE, pd, DA_ProductName, &devname, TAG_END); psdAddErrorMsg(RETURN_OK, (STRPTR) libname, "Play it again, '%s'!", devname); CloseLibrary(ps); return(nch); } } nch->nch_ReadySigTask = NULL; //FreeSignal(nch->nch_ReadySignal); psdFreeVec(nch); } CloseLibrary(ps); } return(NULL); }
static int libInit(LIBBASETYPEPTR nh) { KPRINTF(10, ("libInit nh: 0x%08lx SysBase: 0x%08lx\n", nh, SysBase)); nh->nh_UtilityBase = OpenLibrary("utility.library", 39); #define UtilityBase nh->nh_UtilityBase if(UtilityBase) { /* Create default config */ nh->nh_CurrentCGC.cgc_ChunkID = AROS_LONG2BE(MAKE_ID('C','M','I','D')); nh->nh_CurrentCGC.cgc_Length = AROS_LONG2BE(sizeof(struct ClsGlobalCfg)-8); NewList(&nh->nh_Bindings); } else { KPRINTF(20, ("libInit: OpenLibrary(\"utility.library\", 39) failed!\n")); nh = NULL; } KPRINTF(10, ("libInit: Ok\n")); return(nh ? TRUE : FALSE); }
void *FDtoFilp (int fd) { void *filp; if (fd >= 0 && fd < MAX_FD) { filp = current_process->filedesc[fd]; } else { KPRINTF ("FILP out of range"); SetError (EBADF); filp = NULL; } return filp; }
struct Device *FindDevice (char *name) { struct Device *device; KPRINTF ("FindDevice (%s)", name); device = LIST_HEAD (&device_list); while (device != NULL) { if (StrCmp (name, device->name) == 0) break; device = LIST_NEXT (device, device_entry); } return device; }