⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hif.c

📁 gdb for adsp develop
💻 C
📖 第 1 页 / 共 2 页
字号:
   return (0);   }  /* end hif_lseek() *//*** Service 22 - remove**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    22 (0x16)   Service number**             lr2      pathname    A pointer to string that contains**                                  the pathname of the file**** Returns:    gr96     retval      Success = 0**                                  Failure < 0**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful*/INT32hif_remove(lr2, gr96)UINT32	lr2;UINT32	*gr96;   {   int      retval;   INT32      result;   result = UDI_read_string((INT32) UDI29KDRAMSpace,                        (ADDR32) lr2,                        (INT32) MAX_FILENAME,                        tmp_buffer);   if (result != (INT32) 0) {     *gr96 = (UINT32) -1;      return(result);   }   retval = unlink(tmp_buffer);   if (retval != 0) {     *gr96 = (UINT32) -1;      return(errno);   }   *gr96 = (UINT32) 0;   return (0);   }  /* end hif_remove() *//*** Service 23 - rename**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    23 (0x17)   Service number**             lr2      oldfile     A pointer to string containing**                                  the old pathname of the file**             lr3      newfile     A pointer to string containing**                                  the new pathname of the file**** Returns:    gr96     retval      Success = 0**                                  Failure < 0**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful*/INT32hif_rename(lr2, lr3, gr96)UINT32	lr2, lr3;UINT32	*gr96;   {   char     oldname[MAX_FILENAME];   int      retval;   INT32      result;   /* Get old filename */   result = UDI_read_string((INT32) UDI29KDRAMSpace,                        (ADDR32) lr2,                        (INT32) MAX_FILENAME,                        oldname);   if (result != (INT32) 0) {      *gr96 = (UINT32) -1;      return(result);   }   /* Get new filename */   result = UDI_read_string((INT32) UDI29KDRAMSpace,                        (ADDR32) lr3,                        (INT32) MAX_FILENAME,                        tmp_buffer);   if (result != (INT32) 0) {      *gr96 = (UINT32) -1;      return(result);   }   retval = rename(oldname, tmp_buffer);   *gr96 = (UINT32) retval;   if (retval < 0) {      return(errno);   }   return (0);   }  /* end hif_rename() *//*** Service 24 - ioctl**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    24 (0x18)   Service number**             lr2      fileno      File descriptor number to be tested**             lr3      mode        Operating mode**** Returns:    gr96     retval      Success = 0**                                  Failure < 0**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful**** Note:  There is no equivalent to ioctl() in MS-DOS.  It is**        stubbed to return a zero.*/INT32hif_ioctl(lr2, lr3)UINT32	lr2, lr3;   {   int   des;   int   request;   int   result;   des = (int) lr2;   request = (int) lr3;   result = ioctl(des, request);   if (result == -1)      return(errno);   return (0);   }  /* end hif_ioctl() *//*** Service 25 - iowait**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    25 (0x19)   Service number**             lr2      fileno      File descriptor number to be tested**             lr3      mode        1 = non-blocking completion test**                                  2 = wait until read operation complete**** Returns:    gr96     count       * see HIF spec**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful**** Note:  As with ioctl(), there is no equivalent to iowait() in**        MS-DOS.  It is stubbed to return a zero.*//* ARGSUSED */INT32hif_iowait(lr2, lr3)UINT32	lr2, lr3;   {   return (HIF_EHIFNOTAVAIL);   }  /* end hif_iowait() *//*** Service 26 - iostat**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    26 (0x20)   Service number**             lr2      fileno      File descriptor number to be tested**** Returns:    gr96     iostat      input status**                                  0x0001 = RDREADY**                                  0x0002 = ISATTY**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful**** Note:  Currently RDREADY is always returned as set.  This is**        ok for MS-DOS, but may cause problems in BSD UNIX.***//* ARGSUSED */INT32hif_iostat(lr2, gr96)UINT32	lr2;UINT32	*gr96;   {   UDIError  result;   UINT32  file_no;   *gr96 = (UINT32) RDREADY;   file_no = lr2;   result = (UDIError) isatty((int) file_no);   if (result == (UDIError) 0)      *gr96 = (UINT32) (*gr96 | ISATTY);   return (0);   }  /* end hif_iostat() *//*** Service 33 - tmpnam**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    33 (0x21)   Service number**             lr2      addrptr     Pointer into which filename is**                                  to be stored**** Returns:    gr96     filename    Success: pointer to temporary**                                  filename string.  This will be**                                  the same as lr2 on entry unless**                                  an error occurred**                                  Failure: = 0 (NULL pointer)**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful**** Warnings:  This function does not check environment variables**            such as TMP when creating a temporary filename.****            Also, an input parameter of NULL is not accepted.  This**            would require allocation of a temporary buffer on the**            target for storage of the temporary file name.  The**            target must necessarily specify a buffer address for the**            temporary filename.***/INT32hif_tmpnam(lr2, gr96)UINT32	lr2;UINT32	*gr96;   {   ADDR32  addrptr;   char   *filename;   INT32     result;   /*   ** If addrptr is zero, there is supposed to be a temporary   ** buffer allocated on the target.  Since we can't allocate   ** memory on the target we have to return an error.  This   ** should be fixed.   */   addrptr = lr2;   if (addrptr == (UINT32) 0) {     *gr96 = (UINT32) 0;      return(HIF_EACCESS);   }   filename = tmpnam(tmp_buffer);   if (filename == NULL) {     *gr96 = (UINT32) 0;      return(HIF_EACCESS);   }   result = UDI_write_string((INT32) UDI29KDRAMSpace,                         addrptr,                         (INT32) (strlen(filename) + 1),                         filename);   if (result != (INT32) 0) {      *gr96 = (UINT32) 0;      return(result);   }   *gr96 = (UINT32) addrptr;   return (0);   }  /* end hif_tmpnam() *//*** Service 49 - time**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    49 (0x31)   Service number**** Returns:    gr96     secs        Success != 0 (time in seconds)**                                  Failure = 0**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful*//* ARGSUSED */INT32hif_time(gr96)UINT32	*gr96;   {   time_t  secs;   secs = time((time_t *) 0);   *gr96 = (UINT32) secs;   return (0);   }  /* end hif_time() *//*** Service 65 - getenv**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    65 (0x41)   Service number**             lr2      name        A pointer to symbol name**		lr3	destination - given by OS.**** Returns:    gr96     addrptr     Success: pointer to symbol name string**                                  Failure = 0 (NULL pointer)**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful**** Note:  Since this service requires writing to a buffer on the**        target, an extra parameter has been passed in lr3.**        This parameter points to a buffer which can be used**        by getenv.*/INT32hif_getenv(lr2, lr3, gr96)UINT32	lr2;UINT32	lr3;UINT32	*gr96;   {   char   *varval;   INT32     result;   result = UDI_read_string((INT32) UDI29KDRAMSpace,                        (ADDR32) lr2,                        (INT32) MAX_ENV,                        tmp_buffer);   if (result != (INT32) 0) {      *gr96 = (UINT32) 0;      return(result);   }   varval = (char *) getenv(tmp_buffer);   if (varval == NULL)     result = UDI_write_string((INT32) UDI29KDRAMSpace,                         (ADDR32) lr3,                         (INT32) 4,                         "\0\0\0\0");   else     result = UDI_write_string((INT32) UDI29KDRAMSpace,                         (ADDR32) lr3,                         (INT32) (strlen(varval) + 1),                         varval);   if (result != (INT32) 0) {      *gr96 = (UINT32) 0;      return(result);   }   *gr96 = lr3;   return (0);   }  /* end hif_getenv() *//*** Service 66 - gettz**** Type         Regs    Contents    Description** ----         ----    --------    -----------** Calling:    gr121    66 (0x42)   Service number**** Returns:    gr96     zonecode    Success >= 0 (minutes west of GMT)**                                  Failure < 0 (or information**                                               unavailable)**             gr97     dstcode     Success = 1 (Daylight Savings Time**                                               in effect)**                                          = 0 (Daylight Savings Time**                                               not in effect)**             gr121    0x80000000  Logical TRUE, service successful**                      errcode     error number, service not**                                  successful***//* ARGSUSED */INT32hif_gettz(gr96, gr97)UINT32	*gr96;UINT32	*gr97;   {   struct timeb timeptr;   (void) ftime(&timeptr);   *gr96 = (UINT32) timeptr.timezone;   *gr97 = (UINT32) timeptr.dstflag;   return (0);   }  /* end hif_gettz() *//*** This function is used to read data from the target.** This function returns zero if successful, and an** error code otherwise.**** Note that this function permits reading any** arbitrary sized buffer on the target into a** buffer on the host.*/INT32UDI_read_string(memory_space, address, byte_count, data)   INT32   memory_space;   ADDR32  address;   INT32   byte_count;   char   *data;   {   UDIResource	from;   UDICount	count_done;   UDIError	UDIretval;   from.Offset = address;   from.Space = (CPUSpace) memory_space;   if ((UDIretval = UDIRead (from,			     (UDIHostMemPtr) data,			     (UDICount) byte_count,			     (size_t) 1,			     &count_done,			     (UDIBool) 0)) != UDINoError) {      com_error = 1;      return (UDIretval);   };   if ((tip_target_config.os_version & 0xf) > 4) { /* new HIF kernel */     /*       * Examine UDIretval and send a GO to switch the Debugger context      * back to HIF kernel.      */      Mini_build_go_msg();      if (Mini_msg_send() != SUCCESS) {	com_error = 1;        return (-1);	/* FAILURE */      }   } else { /* old HIF kernel */   }    return(0); /* SUCCESS */   }  /* end read_string() *//*** This function is used to write a buffer of data to** the target.  This function returns zero if successful,** and an error code otherwise.**** Note that this function permits writing any** arbitrary sized buffer on the target from a** buffer on the host.*/INT32UDI_write_string(memory_space, address, byte_count, data)   INT32   memory_space;   ADDR32  address;   INT32   byte_count;   char   *data;   {   UDIResource	to;   UDICount	count_done;   UDIError	UDIretval;   to.Offset = address;   to.Space = (CPUSpace) memory_space;   if ((UDIretval = UDIWrite ((UDIHostMemPtr) data,			      to,			      (UDICount) byte_count,			      (size_t) 1,			      &count_done,			      (UDIBool) 0)) != UDINoError) {      com_error = 1;      return (UDIretval);   }   if ((tip_target_config.os_version & 0xf) > 4) { /* new HIF kernel */     /*       * Examine UDIretval and send a GO to switch the Debugger context      * back to HIF kernel.      */      Mini_build_go_msg();      if (Mini_msg_send() != SUCCESS) {	com_error = 1;        return (-1);	/* FAILURE */      }   } else { /* old HIF kernel */   }    return(0); /* SUCCESS */   }  /* end UDI_write_string() */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -