hw_res.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2010 Lenka Trochtova
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028  
00035 #ifndef LIBC_DEVICE_HW_RES_H_
00036 #define LIBC_DEVICE_HW_RES_H_
00037 
00038 #include <ipc/dev_iface.h>
00039 #include <bool.h>
00040 
00042 typedef enum {
00043         HW_RES_GET_RESOURCE_LIST = 0,
00044         HW_RES_ENABLE_INTERRUPT
00045 } hw_res_method_t;
00046 
00048 typedef enum {
00049         INTERRUPT,
00050         IO_RANGE, 
00051         MEM_RANGE
00052 } hw_res_type_t;
00053 
00054 typedef enum {
00055         LITTLE_ENDIAN = 0,
00056         BIG_ENDIAN
00057 } endianness_t;
00058 
00060 typedef struct {
00061         hw_res_type_t type;
00062         union {
00063                 struct {
00064                         uint64_t address;
00065                         endianness_t endianness;
00066                         size_t size;
00067                 } mem_range;
00068 
00069                 struct {
00070                         uint64_t address;
00071                         endianness_t endianness;
00072                         size_t size;
00073                 } io_range;
00074 
00075                 struct {
00076                         int irq;
00077                 } interrupt;
00078         } res;
00079 } hw_resource_t;
00080 
00081 typedef struct {
00082         size_t count;
00083         hw_resource_t *resources;
00084 } hw_resource_list_t;
00085 
00086 static inline void hw_res_clean_resource_list(hw_resource_list_t *hw_res)
00087 {
00088         if (hw_res->resources != NULL) {
00089                 free(hw_res->resources);
00090 
00091                 hw_res->resources = NULL;
00092         }
00093 
00094         hw_res->count = 0;
00095 }
00096 
00097 extern int hw_res_get_resource_list(int, hw_resource_list_t *);
00098 extern bool hw_res_enable_interrupt(int);
00099 
00100 #endif
00101 

Generated on Thu Jun 2 07:45:46 2011 for HelenOS/USB by  doxygen 1.4.7