Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ACS
Public
HermitCore
libhermit-rs
Commits
b8068482
Commit
b8068482
authored
Jul 04, 2020
by
Stefan Lankes
Committed by
Stefan Lankes
Jul 04, 2020
Browse files
disable virtio_net support to support newlib
parent
9df6a2d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/arch/x86_64/kernel/virtio_net.rs
View file @
b8068482
...
...
@@ -13,6 +13,7 @@ use crate::arch::x86_64::kernel::virtio::{
};
use
crate
::
arch
::
x86_64
::
mm
::
paging
::{
BasePageSize
,
PageSize
};
use
crate
::
arch
::
x86_64
::
mm
::{
paging
,
virtualmem
};
#[cfg(not(feature
=
"newlib"
))]
use
crate
::
drivers
::
net
::
netwakeup
;
use
crate
::
synch
::
spinlock
::
SpinlockIrqSave
;
...
...
@@ -367,6 +368,7 @@ impl<'a> VirtioNetDriver<'a> {
let
isr_status
=
*
(
self
.isr_cfg
);
if
(
isr_status
&
0x1
)
==
0x1
{
// handle incoming packets
#[cfg(not(feature
=
"newlib"
))]
netwakeup
();
return
true
;
...
...
src/drivers/net/mod.rs
View file @
b8068482
...
...
@@ -5,91 +5,57 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#[cfg(feature
=
"newlib"
)]
pub
use
self
::
newlib
::{
netwait
,
netwakeup
};
#[cfg(not(feature
=
"newlib"
))]
pub
use
self
::
nonewlib
::{
netwait
,
netwait_and_wakeup
,
netwakeup
};
#[cfg(feature
=
"newlib"
)]
mod
newlib
{
use
crate
::
synch
::
semaphore
::
*
;
static
NET_SEM
:
Semaphore
=
Semaphore
::
new
(
0
);
pub
fn
netwakeup
()
{
NET_SEM
.release
();
}
pub
fn
netwait
(
millis
:
Option
<
u64
>
)
{
match
millis
{
Some
(
ms
)
=>
{
if
ms
>
0
{
NET_SEM
.acquire
(
Some
(
ms
));
}
else
{
NET_SEM
.try_acquire
();
}
}
_
=>
{
NET_SEM
.acquire
(
None
);
}
};
}
use
crate
::
arch
::
kernel
::
percore
::
*
;
use
crate
::
scheduler
::
task
::
TaskHandle
;
use
crate
::
synch
::
semaphore
::
*
;
use
crate
::
synch
::
spinlock
::
SpinlockIrqSave
;
use
alloc
::
collections
::
BTreeMap
;
static
NET_SEM
:
Semaphore
=
Semaphore
::
new
(
0
);
static
NIC_QUEUE
:
SpinlockIrqSave
<
BTreeMap
<
usize
,
TaskHandle
>>
=
SpinlockIrqSave
::
new
(
BTreeMap
::
new
());
pub
fn
netwakeup
()
{
NET_SEM
.release
();
}
#[cfg(not(feature
=
"newlib"
))]
mod
nonewlib
{
use
crate
::
arch
::
kernel
::
percore
::
*
;
use
crate
::
scheduler
::
task
::
TaskHandle
;
use
crate
::
synch
::
semaphore
::
*
;
use
crate
::
synch
::
spinlock
::
SpinlockIrqSave
;
use
alloc
::
collections
::
BTreeMap
;
static
NET_SEM
:
Semaphore
=
Semaphore
::
new
(
0
);
static
NIC_QUEUE
:
SpinlockIrqSave
<
BTreeMap
<
usize
,
TaskHandle
>>
=
SpinlockIrqSave
::
new
(
BTreeMap
::
new
());
pub
fn
netwakeup
()
{
NET_SEM
.release
();
}
pub
fn
netwait_and_wakeup
(
handles
:
&
[
usize
],
millis
:
Option
<
u64
>
)
{
{
let
mut
guard
=
NIC_QUEUE
.lock
();
pub
fn
netwait_and_wakeup
(
handles
:
&
[
usize
],
millis
:
Option
<
u64
>
)
{
{
let
mut
guard
=
NIC_QUEUE
.lock
();
for
i
in
handles
{
if
let
Some
(
task
)
=
guard
.remove
(
i
)
{
core_scheduler
()
.custom_wakeup
(
task
);
}
for
i
in
handles
{
if
let
Some
(
task
)
=
guard
.remove
(
i
)
{
core_scheduler
()
.custom_wakeup
(
task
);
}
}
NET_SEM
.acquire
(
millis
);
}
pub
fn
netwait
(
handle
:
usize
,
millis
:
Option
<
u64
>
)
{
let
wakeup_time
=
match
millis
{
Some
(
ms
)
=>
Some
(
crate
::
arch
::
processor
::
get_timer_ticks
()
+
ms
*
1000
),
_
=>
None
,
};
let
mut
guard
=
NIC_QUEUE
.lock
();
let
core_scheduler
=
core_scheduler
();
NET_SEM
.acquire
(
millis
);
}
// Block the current task and add it to the wakeup queue.
core_scheduler
.block_current_task
(
wakeup_time
);
guard
.insert
(
handle
,
core_scheduler
.get_current_task_handle
());
pub
fn
netwait
(
handle
:
usize
,
millis
:
Option
<
u64
>
)
{
let
wakeup_time
=
match
millis
{
Some
(
ms
)
=>
Some
(
crate
::
arch
::
processor
::
get_timer_ticks
()
+
ms
*
1000
),
_
=>
None
,
};
let
mut
guard
=
NIC_QUEUE
.lock
();
let
core_scheduler
=
core_scheduler
();
// release lock
drop
(
guard
);
// Block the current task and add it to the wakeup queue.
core_scheduler
.block_current_task
(
wakeup_time
);
guard
.insert
(
handle
,
core_scheduler
.get_current_task_handle
());
//
Switch to the next task.
core_scheduler
.reschedule
(
);
//
release lock
drop
(
guard
);
// if the timer is expired, we have still the task in the btreemap
// => remove it from the btreemap
if
millis
.is_some
()
{
let
mut
guard
=
NIC_QUEUE
.lock
();
// Switch to the next task.
core_scheduler
.reschedule
();
guard
.remove
(
&
handle
);
}
// if the timer is expired, we have still the task in the btreemap
// => remove it from the btreemap
if
millis
.is_some
()
{
let
mut
guard
=
NIC_QUEUE
.lock
();
guard
.remove
(
&
handle
);
}
}
src/syscalls/mod.rs
View file @
b8068482
...
...
@@ -6,6 +6,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#[cfg(not(feature
=
"newlib"
))]
use
crate
::
drivers
::
net
::
*
;
use
crate
::
environment
;
#[cfg(feature
=
"newlib"
)]
...
...
@@ -141,6 +142,7 @@ pub fn sys_rx_buffer_consumed() -> Result<(), ()> {
kernel_function!
(
__sys_rx_buffer_consumed
())
}
#[cfg(not(feature
=
"newlib"
))]
fn
__sys_netwait
(
handle
:
usize
,
millis
:
Option
<
u64
>
)
{
netwait
(
handle
,
millis
)
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment