1 #include <dev/rr232x/rr232x_config.h>
3 * $Id: osm.h,v 1.5 2005/08/18 05:17:43 gmm Exp $
4 * Copyright (C) 2005 HighPoint Technologies, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #define VERMAGIC_OSM 5
33 #define os_max_queue_comm 32
34 #define os_max_sg_descriptors 18
37 #define DMAPOOL_PAGE_SIZE 0x1000 /* PAGE_SIZE (i386/x86_64) */
38 #define os_max_cache_size 0x800000 /* 8MB */
39 #define os_max_cache_pages (os_max_cache_size/DMAPOOL_PAGE_SIZE)
42 typedef unsigned int HPT_UINT, HPT_U32;
43 typedef unsigned long HPT_UPTR;
44 typedef unsigned short HPT_U16;
45 typedef unsigned char HPT_U8;
46 typedef unsigned long HPT_TIME;
47 typedef unsigned long long HPT_U64;
49 #define CPU_TO_LE64(x) (x)
50 #define CPU_TO_LE32(x) (x)
51 #define CPU_TO_LE16(x) (x)
52 #define LE32_TO_CPU(x) (x)
53 #define LE16_TO_CPU(x) (x)
54 #define LE64_TO_CPU(x) (x)
59 typedef void * HPT_PTR;
61 typedef HPT_U64 HPT_LBA;
62 typedef HPT_U32 HPT_RAW_LBA;
63 #define MAX_LBA_VALUE 0xffffffffffffffffull
64 #define MAX_RAW_LBA_VALUE 0xfffffffful
65 #define RAW_LBA(x) ((HPT_U32)(x))
66 #define LO_LBA(x) ((HPT_U32)(x))
67 #define HI_LBA(x) (sizeof(HPT_LBA)>4? (HPT_U32)((x)>>32) : 0)
68 #define LBA_FORMAT_STR "0x%llX"
70 typedef HPT_U64 BUS_ADDRESS;
71 #define LO_BUSADDR(x) ((HPT_U32)(x))
72 #define HI_BUSADDR(x) (sizeof(BUS_ADDRESS)>4? (x)>>32 : 0)
74 typedef unsigned char HPT_BOOL;
78 typedef struct _TIME_RECORD {
79 HPT_U32 seconds:6; /* 0 - 59 */
80 HPT_U32 minutes:6; /* 0 - 59 */
81 HPT_U32 month:4; /* 1 - 12 */
82 HPT_U32 hours:6; /* 0 - 59 */
83 HPT_U32 day:5; /* 1 - 31 */
84 HPT_U32 year:5; /* 0=2000, 31=2031 */
88 HPT_U8 os_inb (void *port);
89 HPT_U16 os_inw (void *port);
90 HPT_U32 os_inl (void *port);
91 void os_outb (void *port, HPT_U8 value);
92 void os_outw (void *port, HPT_U16 value);
93 void os_outl (void *port, HPT_U32 value);
94 void os_insw (void *port, HPT_U16 *buffer, HPT_U32 count);
95 void os_outsw(void *port, HPT_U16 *buffer, HPT_U32 count);
97 extern HPT_U32 __dummy_reg; /* to avoid the compiler warning */
99 #define os_readb(addr) (*(HPT_U8 *)&__dummy_reg = *(volatile HPT_U8 *)(addr))
100 #define os_readw(addr) (*(HPT_U16 *)&__dummy_reg = *(volatile HPT_U16 *)(addr))
101 #define os_readl(addr) (*(HPT_U32 *)&__dummy_reg = *(volatile HPT_U32 *)(addr))
103 #define os_writeb(addr, val) *(volatile HPT_U8 *)(addr) = (HPT_U8)(val)
104 #define os_writew(addr, val) *(volatile HPT_U16 *)(addr) = (HPT_U16)(val)
105 #define os_writel(addr, val) *(volatile HPT_U32 *)(addr) = (HPT_U32)(val)
107 /* PCI configuration space for specified device*/
108 HPT_U8 os_pci_readb (void *osext, HPT_U8 offset);
109 HPT_U16 os_pci_readw (void *osext, HPT_U8 offset);
110 HPT_U32 os_pci_readl (void *osext, HPT_U8 offset);
111 void os_pci_writeb(void *osext, HPT_U8 offset, HPT_U8 value);
112 void os_pci_writew(void *osext, HPT_U8 offset, HPT_U16 value);
113 void os_pci_writel(void *osext, HPT_U8 offset, HPT_U32 value);
115 /* obsolute interface */
116 #define MAX_PCI_BUS_NUMBER 0xff
117 #define MAX_PCI_DEVICE_NUMBER 32
118 #define MAX_PCI_FUNC_NUMBER 8
119 #define pcicfg_read_dword(bus, dev, fn, reg) 0xffff
122 void *os_map_pci_bar(
130 void os_unmap_pci_bar(void *osext, void *base);
132 #define os_kmap_sgptr(psg) (psg->addr._logical)
133 #define os_kunmap_sgptr(ptr)
134 #define os_set_sgptr(psg, ptr) (psg)->addr._logical = (ptr)
137 void *os_add_timer(void *osext, HPT_U32 microseconds, void (*proc)(void *), void *arg);
138 void os_del_timer(void *handle);
139 void os_request_timer(void * osext, HPT_U32 interval);
140 HPT_TIME os_query_time(void);
143 #define OS_SUPPORT_TASK
145 typedef struct _OSM_TASK {
146 struct _OSM_TASK *next;
147 void (*func)(void *vbus, void *data);
152 void os_schedule_task(void *osext, OSM_TASK *task);
155 HPT_U32 os_get_stamp(void);
156 void os_stallexec(HPT_U32 microseconds);
158 #ifndef _SYS_LIBKERN_H_
159 #define memcpy(dst, src, size) __builtin_memcpy((dst), (src), (size))
160 #define memcmp(dst, src, size) __builtin_memcmp((dst), (src), (size))
161 #define strcpy(dst, src) __builtin_strcpy((dst), (src))
162 static __inline void * memset(void *dst, int c, unsigned long size)
165 for (p=(char*)dst; size; size--,p++) *p = c;
170 #define farMemoryCopy(a,b,c) memcpy((char *)(a), (char *)(b), (HPT_U32)c)
173 #define os_register_device(osext, target_id)
174 #define os_unregister_device(osext, target_id)
175 int os_query_remove_device(void *osext, int target_id);
176 int os_revalidate_device(void *osext, int target_id);
178 HPT_U8 os_get_vbus_seq(void *osext);
181 int os_printk(char *fmt, ...);
184 extern int hpt_dbg_level;
185 #define KdPrint(x) do { if (hpt_dbg_level) os_printk x; } while (0)
186 void __os_dbgbreak(const char *file, int line);
187 #define os_dbgbreak() __os_dbgbreak(__FILE__, __LINE__)
188 #define HPT_ASSERT(x) do { if (!(x)) os_dbgbreak(); } while (0)
189 void os_check_stack(const char *location, int size);
190 #define HPT_CHECK_STACK(size) os_check_stack(__FUNCTION__, (size))
193 #define HPT_ASSERT(x)
194 #define HPT_CHECK_STACK(size)
197 #define OsPrint(x) do { os_printk x; } while (0)