Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kernel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
kernel
Commits
d2095d8d
Verified
Commit
d2095d8d
authored
Mar 17, 2019
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in-memory logging, retrievable from sys:log
parent
f7c97129
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
0 deletions
+70
-0
src/arch/x86_64/debug.rs
src/arch/x86_64/debug.rs
+9
-0
src/arch/x86_64/start.rs
src/arch/x86_64/start.rs
+4
-0
src/lib.rs
src/lib.rs
+3
-0
src/log.rs
src/log.rs
+35
-0
src/scheme/sys/log.rs
src/scheme/sys/log.rs
+17
-0
src/scheme/sys/mod.rs
src/scheme/sys/mod.rs
+2
-0
No files found.
src/arch/x86_64/debug.rs
View file @
d2095d8d
...
...
@@ -3,6 +3,7 @@ use core::fmt;
use
spin
::
Mutex
;
use
spin
::
MutexGuard
;
use
log
::{
LOG
,
Log
};
#[cfg(feature
=
"qemu_debug"
)]
use
syscall
::
io
::
Io
;
use
syscall
::
io
::
Pio
;
...
...
@@ -18,6 +19,7 @@ use super::device::serial::COM1;
pub
static
QEMU
:
Mutex
<
Pio
<
u8
>>
=
Mutex
::
new
(
Pio
::
<
u8
>
::
new
(
0x402
));
pub
struct
Writer
<
'a
>
{
log
:
MutexGuard
<
'a
,
Option
<
Log
>>
,
#[cfg(feature
=
"graphical_debug"
)]
display
:
MutexGuard
<
'a
,
Option
<
DebugDisplay
>>
,
#[cfg(feature
=
"qemu_debug"
)]
...
...
@@ -29,6 +31,7 @@ pub struct Writer<'a> {
impl
<
'a
>
Writer
<
'a
>
{
pub
fn
new
()
->
Writer
<
'a
>
{
Writer
{
log
:
LOG
.lock
(),
#[cfg(feature
=
"graphical_debug"
)]
display
:
DEBUG_DISPLAY
.lock
(),
#[cfg(feature
=
"qemu_debug"
)]
...
...
@@ -39,6 +42,12 @@ impl<'a> Writer<'a> {
}
pub
fn
write
(
&
mut
self
,
buf
:
&
[
u8
])
{
{
if
let
Some
(
ref
mut
log
)
=
*
self
.log
{
log
.write
(
buf
);
}
}
#[cfg(feature
=
"graphical_debug"
)]
{
if
let
Some
(
ref
mut
display
)
=
*
self
.display
{
...
...
src/arch/x86_64/start.rs
View file @
d2095d8d
...
...
@@ -16,6 +16,7 @@ use device;
use
gdt
;
use
idt
;
use
interrupt
;
use
log
;
use
memory
;
use
paging
;
...
...
@@ -111,6 +112,9 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! {
// Setup kernel heap
allocator
::
init
(
&
mut
active_table
);
// Activate memory logging
log
::
init
();
// Use graphical debug
#[cfg(feature=
"graphical_debug"
)]
graphical_debug
::
init
(
&
mut
active_table
);
...
...
src/lib.rs
View file @
d2095d8d
...
...
@@ -82,6 +82,9 @@ pub mod event;
/// External functions
pub
mod
externs
;
/// Logging
pub
mod
log
;
/// Memory management
pub
mod
memory
;
...
...
src/log.rs
0 → 100644
View file @
d2095d8d
use
alloc
::
collections
::
VecDeque
;
use
spin
::
Mutex
;
pub
static
LOG
:
Mutex
<
Option
<
Log
>>
=
Mutex
::
new
(
None
);
pub
fn
init
()
{
*
LOG
.lock
()
=
Some
(
Log
::
new
(
1024
*
1024
));
}
pub
struct
Log
{
data
:
VecDeque
<
u8
>
,
size
:
usize
,
}
impl
Log
{
pub
fn
new
(
size
:
usize
)
->
Log
{
Log
{
data
:
VecDeque
::
with_capacity
(
size
),
size
:
size
}
}
pub
fn
read
(
&
self
)
->
(
&
[
u8
],
&
[
u8
])
{
self
.data
.as_slices
()
}
pub
fn
write
(
&
mut
self
,
buf
:
&
[
u8
])
{
for
&
b
in
buf
{
while
self
.data
.len
()
+
1
>=
self
.size
{
self
.data
.pop_front
();
}
self
.data
.push_back
(
b
);
}
}
}
src/scheme/sys/log.rs
0 → 100644
View file @
d2095d8d
use
alloc
::
vec
::
Vec
;
use
log
::
LOG
;
use
syscall
::
error
::
Result
;
pub
fn
resource
()
->
Result
<
Vec
<
u8
>>
{
let
mut
vec
=
Vec
::
new
();
if
let
Some
(
ref
log
)
=
*
LOG
.lock
()
{
let
slices
=
log
.read
();
vec
.reserve_exact
(
slices
.0
.len
()
+
slices
.1
.len
());
vec
.extend_from_slice
(
slices
.0
);
vec
.extend_from_slice
(
slices
.1
);
}
Ok
(
vec
)
}
src/scheme/sys/mod.rs
View file @
d2095d8d
...
...
@@ -14,6 +14,7 @@ mod context;
mod
cpu
;
mod
exe
;
mod
iostat
;
mod
log
;
mod
scheme
;
mod
scheme_num
;
mod
syscall
;
...
...
@@ -43,6 +44,7 @@ impl SysScheme {
files
.insert
(
b
"cpu"
,
Box
::
new
(
move
||
cpu
::
resource
()));
files
.insert
(
b
"exe"
,
Box
::
new
(
move
||
exe
::
resource
()));
files
.insert
(
b
"iostat"
,
Box
::
new
(
move
||
iostat
::
resource
()));
files
.insert
(
b
"log"
,
Box
::
new
(
move
||
log
::
resource
()));
files
.insert
(
b
"scheme"
,
Box
::
new
(
move
||
scheme
::
resource
()));
files
.insert
(
b
"scheme_num"
,
Box
::
new
(
move
||
scheme_num
::
resource
()));
files
.insert
(
b
"syscall"
,
Box
::
new
(
move
||
syscall
::
resource
()));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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