Skip to content

Commit 354d4e5

Browse files
author
zhiayang
committed
misc: move drivers to proper subfolders
1 parent c3fc964 commit 354d4e5

File tree

13 files changed

+111
-3
lines changed

13 files changed

+111
-3
lines changed

Diff for: drivers/devices/makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Makefile for Orion-X4 userspace programs
2+
# Written in 2013
3+
4+
all:
5+
@find . -mindepth 1 -maxdepth 1 -type d -exec $(MAKE) -C {} \;

Diff for: drivers/ps2/.vscode/c_cpp_properties.json renamed to drivers/devices/ps2/.vscode/c_cpp_properties.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"__orionx__",
1212
"_DEBUG"
1313
],
14-
"compilerPath": "${workspaceFolder}/../../build/toolchain/bin/x86_64-orionx-g++",
14+
"compilerPath": "${workspaceFolder:nx}/build/toolchain/bin/x86_64-orionx-g++",
1515
"intelliSenseMode": "clang-x64",
1616
"browse": {
1717
"path": [
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: drivers/fs/makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Makefile for Orion-X4 userspace programs
2+
# Written in 2013
3+
4+
all:
5+
@find . -mindepth 1 -maxdepth 1 -type d -exec $(MAKE) -C {} \;

Diff for: drivers/fs/tarfs/makefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Makefile for UnixCompatLibC.
2+
# Written in 2014
3+
4+
CXXFLAGS = -Wno-pragmas -O2 -std=c++17 -fno-strict-aliasing -Wall
5+
6+
.PHONY: all
7+
8+
all: $(INITRD_DIR)/drivers/ps2
9+
10+
$(INITRD_DIR)/drivers/ps2: source/tarfs.cpp $(SYSROOT)/usr/lib/libc.a $(SYSROOT)/usr/lib/libnxsc.a
11+
@echo "# tarfs"
12+
@$(CXX) $(CXXFLAGS) -o $@ source/tarfs.cpp
13+
14+

Diff for: drivers/fs/tarfs/source/tarfs.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// tarfs.cpp
2+
// Copyright (c) 2020, zhiayang
3+
// Licensed under the Apache License Version 2.0.
4+
5+
#include <stdio.h>
6+
7+
#include <utility>
8+
9+
#include <nx/ipc.h>
10+
#include <svr/vfs.h>
11+
12+
int main(int argc, char** argv)
13+
{
14+
while(true)
15+
{
16+
if(nx::ipc::poll() == 0)
17+
continue;
18+
19+
nx::ipc::message_body_t body;
20+
auto client = nx::ipc::receive(&body);
21+
22+
// vfs::handleCall(client, std::move(body));
23+
}
24+
}

Diff for: drivers/placebo/source/placebo.cpp

+61-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,67 @@ int main()
8484
constexpr uint64_t update_time = 250'000'000;
8585

8686
printf("time for owo\n");
87-
int foozle = 0;
87+
88+
{
89+
syscall::kernel_log(2, "placebo", 7, "trying to vfs...", 16);
90+
91+
using namespace nx;
92+
93+
auto sel = "/proc/name/vfs-svr";
94+
auto id = ipc::find_selector(ipc::selector_t(sel));
95+
if(id == (uint64_t) -1)
96+
{
97+
printf("could not find vfs-svr\n");
98+
abort();
99+
}
100+
101+
auto tmp = ipc::collect_memory_ticket(ipc::create_memory_ticket(1024, 0));
102+
assert(tmp.ptr != nullptr);
103+
104+
auto path = "/initrd/usr/test.txt";
105+
auto plen = strlen(path);
106+
107+
memcpy(tmp.ptr, path, plen);
108+
109+
auto openMsg = vfs::msg::FnOpen {
110+
vfs::msg::Header {
111+
.op = vfs::msg::OP_OPEN,
112+
.sequence = 1
113+
},
114+
/* flags: */ 0,
115+
vfs::Buffer {
116+
.memTicketId = tmp.ticketId,
117+
.offset = 0,
118+
.length = plen
119+
}
120+
};
121+
122+
ipc::send(id, openMsg);
123+
again:
124+
while(ipc::poll() == 0)
125+
;
126+
127+
ipc::message_body_t body;
128+
ipc::receive(&body);
129+
130+
auto reply = ipc::extract<vfs::msg::ResOpen>(body);
131+
if(reply.op != vfs::msg::OP_OPEN)
132+
goto again;
133+
134+
auto handle = reply.handle;
135+
printf("** received handle: %lu\n", handle.id);
136+
137+
// vfs::handleCall(client, std::move(body));
138+
139+
140+
// ipc::release_memory_ticket(tmp);
141+
}
142+
143+
144+
145+
146+
147+
88148
while(true)
89149
{
90150
auto ts = syscall::nanosecond_timestamp();

Diff for: nx.code-workspace

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
},
3535
{
3636
"name": "ps2",
37-
"path": "drivers/ps2"
37+
"path": "drivers/devices/ps2"
3838
},
3939
{
4040
"name": "tty-svr",

0 commit comments

Comments
 (0)