📄 loopback.c
字号:
// This file is part of MANTIS OS, Operating System// See http://mantis.cs.colorado.edu///// Copyright (C) 2003,2004,2005 University of Colorado, Boulder//// This program is free software; you can redistribute it and/or// modify it under the terms of the mos license (see file LICENSE)/* Project Mantis File: loopback.c Authors: Brian Shucker Date: 01-16-04 Implementation of the local loopback network device (Useful for network generality and for IPC)*/#include "mos.h"#include "com.h"#include "sem.h"#include "mutex.h"#include "loopback.h"#if defined(LOOPBACK) || !defined(SCONS)static comBuf *managed_buf;static mos_sem_t recv_sem;static mos_sem_t send_sem;void com_loopback_init(void){ //get initial buffer com_swap_bufs(IFACE_LOOPBACK, NULL, &managed_buf); mos_sem_init(&recv_sem, 0); mos_sem_init(&send_sem, 0); return;}uint8_t com_send_IFACE_LOOPBACK(comBuf *buf){ uint8_t i; mos_mutex_lock(&if_send_mutexes[IFACE_LOOPBACK]); if(managed_buf != NULL) { for(i = 0; i < buf->size; i++) managed_buf->data[i] = buf->data[i]; managed_buf->size = buf->size; } com_swap_bufs(IFACE_LOOPBACK, managed_buf, &managed_buf); mos_sem_post(&send_sem); mos_sem_wait(&send_sem); mos_mutex_unlock(&if_send_mutexes[IFACE_LOOPBACK]); return 0;}void com_ioctl_IFACE_LOOPBACK(uint8_t request, ...){ return;}void com_mode_IFACE_LOOPBACK(uint8_t mode){ return;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -