1.1 --- a/pkg/devices/util/src/memory.cc Sat Jun 06 01:22:58 2020 +0200
1.2 +++ b/pkg/devices/util/src/memory.cc Sat Jun 13 18:04:14 2020 +0200
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 - * Memory allocation utility functions.
1.6 + * Memory and resource allocation utility functions.
1.7 *
1.8 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
1.9 + * Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
1.10 *
1.11 * This program is free software; you can redistribute it and/or
1.12 * modify it under the terms of the GNU General Public License as
1.13 @@ -33,6 +33,29 @@
1.14 return l4io_lookup_device(hid, dh, 0, rh);
1.15 }
1.16
1.17 +int get_irq(char const *hid, l4_uint32_t *start, l4_uint32_t *end)
1.18 +{
1.19 + l4io_device_handle_t dh;
1.20 + l4io_resource_handle_t rh;
1.21 + l4io_resource_t res;
1.22 + int result;
1.23 +
1.24 + result = get_device(hid, &dh, &rh);
1.25 +
1.26 + if (result < 0)
1.27 + return result;
1.28 +
1.29 + result = get_resource(dh, &res, L4IO_RESOURCE_IRQ);
1.30 +
1.31 + if (result)
1.32 + return result;
1.33 +
1.34 + *start = res.start;
1.35 + *end = res.end;
1.36 +
1.37 + return result;
1.38 +}
1.39 +
1.40 int get_resource(l4io_device_handle_t dh, l4io_resource_t *res,
1.41 enum l4io_resource_types_t type)
1.42 {