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

📄 api.h

📁 上一个上传的有问题,这个是好的。visopsys包括系统内核和GUI的全部SOURCE code ,还包括一些基本的docs文档。里面src子目录对应所有SOURCE code.对于想研究操作系统的朋
💻 H
📖 第 1 页 / 共 5 页
字号:
_X_ static inline int fileRead(file *f, unsigned blocknum, unsigned blocks, void *buff){  // Proto: int kernelFileRead(file *, unsigned int, unsigned int, void *);  // Desc : Read data from the previously opened file 'f'.  'f' should have been opened in a read or read/write mode.  Read 'blocks' blocks (see the filesystem functions for information about getting the block size of a given filesystem) and put them in buffer 'buff'.  return (syscall_4(_fnum_fileRead, (void *) f, (void *) blocknum, 		    (void *) blocks, buff));}_X_ static inline int fileWrite(file *f, unsigned blocknum, unsigned blocks, void *buff){  // Proto: int kernelFileWrite(file *, unsigned, unsigned, void *);  // Desc : Write data to the previously opened file 'f'.  'f' should have been opened in a write or read/write mode.  Write 'blocks' blocks (see the filesystem functions for information about getting the block size of a given filesystem) from the buffer 'buff'.  return (syscall_4(_fnum_fileWrite, (void *) f, (void *) blocknum, 		    (void *) blocks, buff));}_X_ static inline int fileDelete(const char *name){  // Proto: int kernelFileDelete(const char *);  // Desc : Delete the file referenced by the pathname 'name'.  return (syscall_1(_fnum_fileDelete, (void *) name));}_X_ static inline int fileDeleteRecursive(const char *name){  // Proto: int kernelFileDeleteRecursive(const char *);  // Desc : Recursively delete filesystem items, starting with the one referenced by the pathname 'name'.  return (syscall_1(_fnum_fileDeleteRecursive, (void *) name));}_X_ static inline int fileDeleteSecure(const char *name, int passes){  // Proto: int kernelFileDeleteSecure(const char *);  // Desc : Securely delete the file referenced by the pathname 'name'.  'passes' indicates the number of times to overwrite the file.  The file is overwritten (number - 1) times with random data, and then NULLs.  A larger number of passes is more secure but takes longer.  return (syscall_2(_fnum_fileDeleteSecure, (void *) name, (void *) passes));}_X_ static inline int fileMakeDir(const char *name){  // Proto: int kernelFileMakeDir(const char *);  // Desc : Create a directory to be referenced by the pathname 'name'.  return (syscall_1(_fnum_fileMakeDir, (void *)name));}_X_ static inline int fileRemoveDir(const char *name){  // Proto: int kernelFileRemoveDir(const char *);  // Desc : Remove the directory referenced by the pathname 'name'.  return (syscall_1(_fnum_fileRemoveDir, (void *)name));}_X_ static inline int fileCopy(const char *src, const char *dest){  // Proto: int kernelFileCopy(const char *, const char *);  // Desc : Copy the file referenced by the pathname 'src' to the pathname 'dest'.  This will overwrite 'dest' if it already exists.  return (syscall_2(_fnum_fileCopy, (void *) src, (void *) dest));}_X_ static inline int fileCopyRecursive(const char *src, const char *dest){  // Proto: int kernelFileCopyRecursive(const char *, const char *);  // Desc : Recursively copy the file referenced by the pathname 'src' to the pathname 'dest'.  If 'src' is a regular file, the result will be the same as using the non-recursive call.  However if it is a directory, all contents of the directory and its subdirectories will be copied.  This will overwrite any files in the 'dest' tree if they already exist.  return (syscall_2(_fnum_fileCopyRecursive, (void *) src, (void *) dest));}_X_ static inline int fileMove(const char *src, const char *dest){  // Proto: int kernelFileMove(const char *, const char *);  // Desc : Move (rename) a file referenced by the pathname 'src' to the pathname 'dest'.  return (syscall_2(_fnum_fileMove, (void *) src, (void *) dest));}_X_ static inline int fileTimestamp(const char *name){  // Proto: int kernelFileTimestamp(const char *);  // Desc : Update the time stamp on the file referenced by the pathname 'name'  return (syscall_1(_fnum_fileTimestamp, (void *) name));}_X_ static inline int fileGetTemp(file *f){  // Proto: int kernelFileGetTemp(void);  // Desc : Create and open a temporary file in write mode.  return (syscall_1(_fnum_fileGetTemp, f));}_X_ static inline int fileStreamOpen(const char *name, int mode, fileStream *f){  // Proto: int kernelFileStreamOpen(const char *, int, fileStream *);  // Desc : Open the file referenced by the pathname 'name' for streaming operations, using the open mode 'mode' (defined in <sys/file.h>).  Fills the fileStream data structure 'f' with information needed for subsequent filestream operations.  return (syscall_3(_fnum_fileStreamOpen, (char *) name, (void *) mode,		    (void *) f));}_X_ static inline int fileStreamSeek(fileStream *f, int offset){  // Proto: int kernelFileStreamSeek(fileStream *, int);  // Desc : Seek the filestream 'f' to the absolute position 'offset'  return (syscall_2(_fnum_fileStreamSeek, (void *) f, (void *) offset));}_X_ static inline int fileStreamRead(fileStream *f, unsigned bytes, char *buff){  // Proto: int kernelFileStreamRead(fileStream *, unsigned, char *);  // Desc : Read 'bytes' bytes from the filestream 'f' and put them into 'buff'.  return (syscall_3(_fnum_fileStreamRead, (void *) f, (void *) bytes, buff));}_X_ static inline int fileStreamReadLine(fileStream *f, unsigned bytes, char *buff){  // Proto: int kernelFileStreamReadLine(fileStream *, unsigned, char *);  // Desc : Read a complete line of text from the filestream 'f', and put up to 'bytes' characters into 'buff'  return (syscall_3(_fnum_fileStreamReadLine, (void *) f, (void *) bytes,		    buff));}_X_ static inline int fileStreamWrite(fileStream *f, unsigned bytes, char *buff){  // Proto: int kernelFileStreamWrite(fileStream *, unsigned, char *);  // Desc : Write 'bytes' bytes from the buffer 'buff' to the filestream 'f'.  return (syscall_3(_fnum_fileStreamWrite, (void *) f, (void *) bytes, buff));}_X_ static inline int fileStreamWriteStr(fileStream *f, char *buff){  // Proto: int kernelFileStreamWriteStr(fileStream *, char *);  // Desc : Write the string in 'buff' to the filestream 'f'  return (syscall_2(_fnum_fileStreamWriteStr, (void *) f, buff));}_X_ static inline int fileStreamWriteLine(fileStream *f, char *buff){  // Proto: int kernelFileStreamWriteLine(fileStream *, char *);  // Desc : Write the string in 'buff' to the filestream 'f', and add a newline at the end  return (syscall_2(_fnum_fileStreamWriteLine, (void *) f, buff));}_X_ static inline int fileStreamFlush(fileStream *f){  // Proto: int kernelFileStreamFlush(fileStream *);  // Desc : Flush filestream 'f'.  return (syscall_1(_fnum_fileStreamFlush, (void *) f));}_X_ static inline int fileStreamClose(fileStream *f){  // Proto: int kernelFileStreamClose(fileStream *);  // Desc : [Flush and] close the filestream 'f'.  return (syscall_1(_fnum_fileStreamClose, (void *) f));}//// Memory functions//_X_ static inline void *memoryGet(unsigned size, const char *desc){  // Proto: void *kernelMemoryGet(unsigned, const char *);  // Desc : Return a pointer to a new block of memory of size 'size' and (optional) physical alignment 'align', adding the (optional) description 'desc'.  If no specific alignment is required, use '0'.  Memory allocated using this function is automatically cleared (like 'calloc').  return ((void *) syscall_2(_fnum_memoryGet, (void *) size, (void *) desc));}_X_ static inline void *memoryGetPhysical(unsigned size, unsigned align, const char *desc){  // Proto: void *kernelMemoryGetPhysical(unsigned, unsigned, const char *);  // Desc : Return a pointer to a new physical block of memory of size 'size' and (optional) physical alignment 'align', adding the (optional) description 'desc'.  If no specific alignment is required, use '0'.  Memory allocated using this function is NOT automatically cleared.  'Physical' refers to an actual physical memory address, and is not necessarily useful to external programs.  return ((void *) syscall_3(_fnum_memoryGetPhysical, (void *) size,			     (void *) align, (void *) desc));}_X_ static inline int memoryRelease(void *p){  // Proto: int kernelMemoryRelease(void *);  // Desc : Release the memory block starting at the address 'p'.  Must have been previously allocated using the memoryRequestBlock() function.  return (syscall_1(_fnum_memoryRelease, p));}_X_ static inline int memoryReleaseAllByProcId(int pid){  // Proto: int kernelMemoryReleaseAllByProcId(int);  // Desc : Release all memory allocated to/by the process referenced by process ID 'pid'.  Only privileged functions can release memory owned by other processes.  return (syscall_1(_fnum_memoryReleaseAllByProcId, (void *) pid));}_X_ static inline int memoryChangeOwner(int opid, int npid, void *addr, void **naddr){  // Proto: int kernelMemoryChangeOwner(int, int, void *, void **);  // Desc : Change the ownership of an allocated block of memory beginning at address 'addr'.  'opid' is the process ID of the currently owning process, and 'npid' is the process ID of the intended new owner.  'naddr' is filled with the new address of the memory (since it changes address spaces in the process).  Note that only a privileged process can change memory ownership.  return (syscall_4(_fnum_memoryChangeOwner, (void *) opid, (void *) npid, 		    addr, (void *) naddr));}_X_ static inline int memoryGetStats(memoryStats *stats, int kernel){  // Proto: int kernelMemoryGetStats(memoryStats *, int);  // Desc : Returns the current memory totals and usage values to the current output stream.  If non-zero, the flag 'kernel' will return kernel heap statistics instead of overall system statistics.  return (syscall_2(_fnum_memoryGetStats, stats, (void *) kernel));}_X_ static inline int memoryGetBlocks(memoryBlock *blocksArray, unsigned buffSize, int kernel){  // Proto: int kernelMemoryGetBlocks(memoryBlock *, unsigned, int);  // Desc : Returns a copy of the array of used memory blocks in 'blocksArray', up to 'buffSize' bytes.  If non-zero, the flag 'kernel' will return kernel heap blocks instead of overall heap allocations.  return (syscall_3(_fnum_memoryGetBlocks, blocksArray, (void *) buffSize,		    (void *) kernel));}_X_ static inline int memoryBlockInfo(void *p, memoryBlock *block){  // Proto: int kernelMemoryBlockInfo(void *, memoryBlock *);  // Desc : Fills in the structure 'block' with information about the allocated memory block starting at virtual address 'p'  return (syscall_2(_fnum_memoryBlockInfo, p, block));}//// Multitasker functions//_X_ static inline int multitaskerCreateProcess(const char *name, int privilege, processImage *execImage){  // Proto: int kernelMultitaskerCreateProcess(const char *, int, processImage *);  // Desc : Create a new process.  'name' will be the new process' name.  'privilege' is the privilege level.  'execImage' is a processImage structure that describes the loaded location of the file, the program's desired virtual address, entry point, size, etc.  If the value returned by the call is a positive integer, the call was successful and the value is the new process' process ID.  New processes are created and left in a stopped state, so if you want it to run you will need to set it to a running state ('ready', actually) using the function call multitaskerSetProcessState().  return (syscall_3(_fnum_multitaskerCreateProcess, (void *) name,		    (void *) privilege, execImage));}_X_ static inline int multitaskerSpawn(void *addr, const char *name, int numargs, void *args[]){  // Proto: int kernelMultitaskerSpawn(void *, const char *, int, void *[]);  // Desc : Spawn a thread from the current process.  The starting point of the code (for example, a function address) should be specified as 'addr'.  'name' will be the new thread's name.  'numargs' and 'args' will be passed as the "int argc, char *argv[]) parameters of the new thread.  If there are no arguments, these should be 0 and NULL, respectively.  If the value returned by the call is a positive integer, the call was successful and the value is the new thread's process ID.  New threads are created and made runnable, so there is no need to change its state to activate it.  return (syscall_4(_fnum_multitaskerSpawn, addr, (void *) name, 		    (void *) numargs, args));}_X_ static inline int multitaskerGetCurrentProcessId(void){  // Proto: int kernelMultitaskerGetCurrentProcessId(void);  // Desc : Returns the process ID of the calling program.  return (syscall_0(_fnum_multitaskerGetCurrentProcessId));}_X_ static inline int multitaskerGetProcess(int pid, process *proc){  // Proto: int kernelMultitaskerGetProcess(int, process *);  // Desc : Returns the process structure for the supplied process ID.  return (syscall_2(_fnum_multitaskerGetProcess, (void *) pid, proc));}_X_ static inline int multitaskerGetProcessByName(const char *name, process *proc){  // Proto: int kernelMultitaskerGetProcessByName(const char *, process *);  // Desc : Returns the process structure for the supplied process name  return (syscall_2(_fnum_multitaskerGetProcessByName, (void *) name, proc));}_X_ static inline int multitaskerGetProcesses(void *buffer, unsigned buffSize){  // Proto: int kernelMultitaskerGetProcesses(void *, unsigned);  // Desc : Fills 'buffer' with up to 'buffSize' bytes' worth of process structures, and returns the number of structures copied.  return (syscall_2(_fnum_multitaskerGetProcesses, buffer, (void *) buffSize));}_X_ static inline int multitaskerSetProcessState(int pid, int state){  // Proto: int kernelMultitaskerSetProcessState(int, kernelProcessState);  // Desc : Sets the state of the process referenced by process ID 'pid' to the new state 'state'.  return (syscall_2(_fnum_multitaskerSetProcessState, (void *) pid,		    (void *) state));}_X_ static inline int multitaskerProcessIsAlive(int pid){  // Proto: int kernelMultitaskerProcessIsAlive(int);  // Desc : Returns 1 if the process with the id 'pid' still exists and is in a 'runnable' (viable) state.  Returns 0 if the process does not exist or is in a 'finished' state.  return (syscall_1(_fnum_mu

⌨️ 快捷键说明

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