Skip to content

Commit

Permalink
general: Update to new libasync mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
avdgrinten committed May 25, 2018
1 parent 35484fe commit 740c92b
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 59 deletions.
8 changes: 5 additions & 3 deletions drivers/block/ata/src/main.cpp
Expand Up @@ -216,9 +216,11 @@ Controller globalController;
int main() {
printf("block-ata: Starting driver\n");

globalController.run();
{
async::queue_scope scope{helix::globalQueue()};
globalController.run();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();
}

8 changes: 5 additions & 3 deletions drivers/clocktracker/src/main.cpp
Expand Up @@ -163,10 +163,12 @@ COFIBER_ROUTINE(cofiber::no_future, initializeDriver(), ([] {
int main() {
std::cout << "drivers/clocktracker: Starting driver" << std::endl;

initializeDriver();
{
async::queue_scope scope{helix::globalQueue()};
initializeDriver();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
10 changes: 6 additions & 4 deletions drivers/gfx/bochs/src/main.cpp
Expand Up @@ -505,11 +505,13 @@ COFIBER_ROUTINE(cofiber::no_future, observeControllers(), ([] {

int main() {
printf("gfx/bochs: Starting driver\n");

observeControllers();

while(true)
helix::Dispatcher::global().dispatch();
{
async::queue_scope scope{helix::globalQueue()};
observeControllers();
}

helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/gfx/intel/src/main.cpp
Expand Up @@ -603,10 +603,12 @@ COFIBER_ROUTINE(cofiber::no_future, observeControllers(), ([] {
int main() {
printf("Starting Intel graphics driver\n");

observeControllers();
{
async::queue_scope scope{helix::globalQueue()};
observeControllers();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/gfx/plainfb/src/main.cpp
Expand Up @@ -422,10 +422,12 @@ COFIBER_ROUTINE(cofiber::no_future, observeControllers(), ([] {
int main() {
std::cout << "gfx/plainfb: Starting driver" << std::endl;

observeControllers();
{
async::queue_scope scope{helix::globalQueue()};
observeControllers();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/gfx/virtio/src/main.cpp
Expand Up @@ -674,10 +674,12 @@ COFIBER_ROUTINE(cofiber::no_future, observeControllers(), ([] {
int main() {
std::cout << "gfx/virtio: Starting driver" << std::endl;

observeControllers();
{
async::queue_scope scope{helix::globalQueue()};
observeControllers();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
19 changes: 10 additions & 9 deletions drivers/kbd/src/main.cpp
Expand Up @@ -508,18 +508,19 @@ int main() {
sendByte(0xF4);
mouseState = kMouseWaitForAck;

runKbd();
runMouse();
{
async::queue_scope scope{helix::globalQueue()};

std::cout << "ps2-hid: mbus objects are ready" << std::endl;
runKbd();
runMouse();
std::cout << "ps2-hid: mbus objects are ready" << std::endl;

handleKbdIrqs();
handleMouseIrqs();
// pollController();

while(true) {
helix::Dispatcher::global().dispatch();
handleKbdIrqs();
handleMouseIrqs();
// pollController();
}

helix::globalQueue()->run();

return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions drivers/uart/src/main.cpp
Expand Up @@ -262,8 +262,7 @@ int main() {

handleIrqs();

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/usb/devices/hid/src/main.cpp
Expand Up @@ -659,10 +659,12 @@ int main() {

// HEL_CHECK(helSetPriority(kHelThisThread, 2));

observeDevices();
{
async::queue_scope scope{helix::globalQueue()};
observeDevices();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/usb/devices/storage/src/main.cpp
Expand Up @@ -214,10 +214,12 @@ COFIBER_ROUTINE(cofiber::no_future, observeDevices(), ([] {
int main() {
std::cout << "block-usb: Starting driver" << std::endl;

observeDevices();
{
async::queue_scope scope{helix::globalQueue()};
observeDevices();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/usb/hcds/ehci/src/main.cpp
Expand Up @@ -1006,10 +1006,12 @@ int main() {

// HEL_CHECK(helSetPriority(kHelThisThread, 2));

observeControllers();
{
async::queue_scope scope{helix::globalQueue()};
observeControllers();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/usb/hcds/uhci/src/main.cpp
Expand Up @@ -1072,10 +1072,12 @@ int main() {

// HEL_CHECK(helSetPriority(kHelThisThread, 2));

observeControllers();
{
async::queue_scope scope{helix::globalQueue()};
observeControllers();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();

return 0;
}
Expand Down
8 changes: 5 additions & 3 deletions drivers/virtio/src/main-block.cpp
Expand Up @@ -69,9 +69,11 @@ int main() {

// HEL_CHECK(helSetPriority(kHelThisThread, 3));

observeDevices();
{
async::queue_scope scope{helix::globalQueue()};
observeDevices();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();
}

6 changes: 4 additions & 2 deletions hel/include/helix/ipc.hpp
Expand Up @@ -203,7 +203,7 @@ struct Context {
virtual void complete(ElementHandle element) = 0;
};

struct Dispatcher {
struct Dispatcher : async::io_service {
friend struct ElementHandle;

private:
Expand Down Expand Up @@ -246,7 +246,7 @@ struct Dispatcher {
return _handle;
}

void dispatch() {
void wait() override {
while(true) {
if(_retrieveIndex == _nextIndex) {
assert(_activeChunks < (1 << sizeShift));
Expand Down Expand Up @@ -853,6 +853,8 @@ inline Submission submitAwaitEvent(BorrowedDescriptor descriptor, AwaitEvent *op
return {descriptor, operation, sequence, dispatcher};
}

async::run_queue *globalQueue();

} // namespace helix

#endif // HELIX_HPP
Expand Down
5 changes: 5 additions & 0 deletions hel/src/globals.cpp
Expand Up @@ -12,5 +12,10 @@ Dispatcher &Dispatcher::global() {
return dispatcher;
}

async::run_queue *globalQueue() {
static async::run_queue queue{&Dispatcher::global()};
return &queue;
}

} // namespace helix

8 changes: 5 additions & 3 deletions mbus/src/main.cpp
Expand Up @@ -399,9 +399,11 @@ int main() {
if(peekauxval(AT_XPIPE, &xpipe))
throw std::runtime_error("No AT_XPIPE specified");

serve(helix::UniqueLane(xpipe));
{
async::queue_scope scope{helix::globalQueue()};
serve(helix::UniqueLane(xpipe));
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();
}

1 change: 1 addition & 0 deletions posix/subsystem/src/inotify.cpp
Expand Up @@ -32,6 +32,7 @@ struct OpenFile : File {

COFIBER_ROUTINE(expected<PollResult>, poll(uint64_t sequence) override, ([=] {
std::cout << "posix: Fix inotify::poll()" << std::endl;
COFIBER_AWAIT cofiber::suspend_always{};
}))

helix::BorrowedDescriptor getPassthroughLane() override {
Expand Down
22 changes: 13 additions & 9 deletions posix/subsystem/src/main.cpp
Expand Up @@ -1557,17 +1557,21 @@ int main() {
std::cout << "Starting posix-subsystem" << std::endl;

// HEL_CHECK(helSetPriority(kHelThisThread, 1));

{
async::queue_scope scope{helix::globalQueue()};

drvcore::initialize();

drvcore::initialize();
charRegistry.install(createHeloutDevice());
charRegistry.install(pts::createMasterDevice());
block_subsystem::run();
drm_subsystem::run();
input_subsystem::run();

charRegistry.install(createHeloutDevice());
charRegistry.install(pts::createMasterDevice());
block_subsystem::run();
drm_subsystem::run();
input_subsystem::run();
runInit();
runInit();
}

while(true)
helix::Dispatcher::global().dispatch();
helix::globalQueue()->run();
}

1 change: 1 addition & 0 deletions posix/subsystem/src/signalfd.cpp
Expand Up @@ -30,6 +30,7 @@ struct OpenFile : File {

COFIBER_ROUTINE(expected<PollResult>, poll(uint64_t sequence) override, ([=] {
std::cout << "posix: Fix signalfd::poll()" << std::endl;
COFIBER_AWAIT cofiber::suspend_always{};
}))

helix::BorrowedDescriptor getPassthroughLane() override {
Expand Down

0 comments on commit 740c92b

Please sign in to comment.