FreeNOS
NetworkServer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Niek Linnenbank
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <Assert.h>
19 #include "NetworkServer.h"
20 
22  : DeviceServer(path)
23  , m_device(ZERO)
24 {
25 }
26 
28 {
29 }
30 
32 {
33  registerDevice(dev, "io");
34  m_device = dev;
35 }
36 
38 {
39  DEBUG("");
40  return DeviceServer::initialize();
41 }
42 
44 {
45  DEBUG("pid = " << pid);
46 
47  if (m_device != ZERO)
48  {
50  }
51 }
52 
54 {
55  assert(m_device != ZERO);
56 
57  // Process all pending requests
59  {
60  }
61 
62  // Start DMA engine
63  const FileSystem::Result result = m_device->startDMA();
64  if (result != FileSystem::Success)
65  {
66  ERROR("failed to start DMA: result = " << (int) result);
67  }
68 
69  // All requests done
70  return false;
71 }
NetworkDevice::startDMA
virtual FileSystem::Result startDMA()
Start DMA processing.
Definition: NetworkDevice.cpp:101
NetworkServer::onProcessTerminated
virtual void onProcessTerminated(const ProcessID pid)
Called whenever another Process is terminated.
Definition: NetworkServer.cpp:43
NetworkServer::m_device
NetworkDevice * m_device
Network device instance.
Definition: NetworkServer.h:85
FileSystemServer::retryRequests
virtual bool retryRequests()
Retry any pending requests.
Definition: FileSystemServer.cpp:629
NetworkDevice
Network Device abstract class.
Definition: NetworkDevice.h:41
Assert.h
ProcessID
u32 ProcessID
Process Identification Number.
Definition: Types.h:140
FileSystem::Success
@ Success
Definition: FileSystem.h:54
NetworkServer::registerNetworkDevice
void registerNetworkDevice(NetworkDevice *dev)
Register network device.
Definition: NetworkServer.cpp:31
DeviceServer
Device driver server.
Definition: DeviceServer.h:43
DeviceServer::registerDevice
void registerDevice(Device *dev, const char *path)
Add a Device.
Definition: DeviceServer.cpp:67
DEBUG
#define DEBUG(msg)
Output a debug message to standard output.
Definition: Log.h:89
DeviceServer::initialize
virtual FileSystem::Result initialize()
Initialize DeviceServer.
Definition: DeviceServer.cpp:30
NetworkServer::NetworkServer
NetworkServer(const char *path)
Constructor.
Definition: NetworkServer.cpp:21
assert
#define assert(exp)
Insert program diagnostics.
Definition: assert.h:60
ERROR
#define ERROR(msg)
Output an error message.
Definition: Log.h:61
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
NetworkServer.h
NetworkServer::initialize
virtual FileSystem::Result initialize()
Initialize the NetworkServer.
Definition: NetworkServer.cpp:37
NetworkDevice::unregisterSockets
void unregisterSockets(const ProcessID pid)
Remove sockets for a process.
Definition: NetworkDevice.cpp:84
NetworkServer::retryRequests
virtual bool retryRequests()
Starts DMA on NetworkDevices after all pending requests are done.
Definition: NetworkServer.cpp:53
ZERO
#define ZERO
Zero value.
Definition: Macros.h:43
NetworkServer::~NetworkServer
virtual ~NetworkServer()
Destructor.
Definition: NetworkServer.cpp:27