From f7d80a9bf99927ea5b85c775a36f050a8eda2e46 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 3 May 2017 08:01:42 -0500 Subject: [PATCH] drivers/ahci: clean exit when no controllers are found Fix #2402 --- repos/os/src/drivers/ahci/ahci.h | 2 ++ repos/os/src/drivers/ahci/main.cc | 11 ++++++++++- repos/os/src/drivers/ahci/spec/x86/platform.cc | 3 +-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/repos/os/src/drivers/ahci/ahci.h b/repos/os/src/drivers/ahci/ahci.h index e4ebe0f94..951be3e01 100644 --- a/repos/os/src/drivers/ahci/ahci.h +++ b/repos/os/src/drivers/ahci/ahci.h @@ -43,6 +43,8 @@ namespace Ahci_driver { Block::Driver *claim_port(long device_num); void free_port(long device_num); + + struct Missing_controller { }; } diff --git a/repos/os/src/drivers/ahci/main.cc b/repos/os/src/drivers/ahci/main.cc index 681f1d129..2b8ccaac9 100644 --- a/repos/os/src/drivers/ahci/main.cc +++ b/repos/os/src/drivers/ahci/main.cc @@ -182,7 +182,16 @@ struct Block::Main { Genode::log("--- Starting AHCI driver ---"); bool support_atapi = config.xml().attribute_value("atapi", false); - Ahci_driver::init(env, heap, root, support_atapi); + try { Ahci_driver::init(env, heap, root, support_atapi); } + + catch (Ahci_driver::Missing_controller) { + Genode::error("no AHCI controller found"); + env.parent().exit(~0); + } + catch (Genode::Parent::Service_denied) { + Genode::error("hardware access denied"); + env.parent().exit(~0); + } } }; diff --git a/repos/os/src/drivers/ahci/spec/x86/platform.cc b/repos/os/src/drivers/ahci/spec/x86/platform.cc index fe0bdadc1..18d0607dd 100644 --- a/repos/os/src/drivers/ahci/spec/x86/platform.cc +++ b/repos/os/src/drivers/ahci/spec/x86/platform.cc @@ -49,8 +49,7 @@ struct X86_hba : Platform::Hba [&] () { pci.upgrade_ram(4096); }); if (!pci_device_cap.valid()) { - Genode::error("no AHCI controller found"); - throw -1; + throw Ahci_driver::Missing_controller(); } /* construct pci client */