1.1 --- a/pkg/devices/util/include/memory.h Sat Jun 06 01:22:58 2020 +0200
1.2 +++ b/pkg/devices/util/include/memory.h 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 @@ -25,10 +25,16 @@
1.14 #include <l4/re/env.h>
1.15 #include <l4/util/util.h>
1.16
1.17 +EXTERN_C_BEGIN
1.18 +
1.19 int get_device(char const *hid, l4io_device_handle_t *dh,
1.20 l4io_resource_handle_t *rh);
1.21
1.22 +int get_irq(char const *hid, l4_uint32_t *start, l4_uint32_t *end);
1.23 +
1.24 int get_resource(l4io_device_handle_t dh, l4io_resource_t *res,
1.25 enum l4io_resource_types_t type);
1.26
1.27 int get_memory(char const *hid, l4_addr_t *start, l4_addr_t *end);
1.28 +
1.29 +EXTERN_C_END
2.1 --- a/pkg/devices/util/src/memory.cc Sat Jun 06 01:22:58 2020 +0200
2.2 +++ b/pkg/devices/util/src/memory.cc Sat Jun 13 18:04:14 2020 +0200
2.3 @@ -1,7 +1,7 @@
2.4 /*
2.5 - * Memory allocation utility functions.
2.6 + * Memory and resource allocation utility functions.
2.7 *
2.8 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk>
2.9 + * Copyright (C) 2018, 2019 Paul Boddie <paul@boddie.org.uk>
2.10 *
2.11 * This program is free software; you can redistribute it and/or
2.12 * modify it under the terms of the GNU General Public License as
2.13 @@ -33,6 +33,29 @@
2.14 return l4io_lookup_device(hid, dh, 0, rh);
2.15 }
2.16
2.17 +int get_irq(char const *hid, l4_uint32_t *start, l4_uint32_t *end)
2.18 +{
2.19 + l4io_device_handle_t dh;
2.20 + l4io_resource_handle_t rh;
2.21 + l4io_resource_t res;
2.22 + int result;
2.23 +
2.24 + result = get_device(hid, &dh, &rh);
2.25 +
2.26 + if (result < 0)
2.27 + return result;
2.28 +
2.29 + result = get_resource(dh, &res, L4IO_RESOURCE_IRQ);
2.30 +
2.31 + if (result)
2.32 + return result;
2.33 +
2.34 + *start = res.start;
2.35 + *end = res.end;
2.36 +
2.37 + return result;
2.38 +}
2.39 +
2.40 int get_resource(l4io_device_handle_t dh, l4io_resource_t *res,
2.41 enum l4io_resource_types_t type)
2.42 {