Fixed uninitialised n_chunks in untested vpcreate
[marionette.git] / kernel / portio.h
blobe1f4f994f7d57ae8f6f1c7716baf8dde06b0a8b6
1 /*
2 * Copyright (c) 2008 Joshua Phillips. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
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
12 * the documentation and/or other materials provided with the
13 * distribution.
15 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef PORTIO_H
29 #define PORTIO_H
31 #include "stddef.h"
33 static inline void outb(int port, unsigned char value)
35 asm volatile ("outb %%al,%%dx" :: "a" (value), "d" (port));
38 static inline void outw(int port, unsigned short value)
40 asm volatile ("outw %%ax,%%dx" :: "a" (value), "d" (port));
43 static inline void outl(int port, unsigned long value)
45 asm volatile ("outl %%eax,%%dx" :: "a" (value), "d" (port));
48 static inline unsigned char inb(int port)
50 unsigned char value;
51 asm volatile ("inb %%dx,%%al" : "=a" (value) : "d" (port));
52 return value;
55 static inline unsigned short inw(int port)
57 unsigned short value;
58 asm volatile ("inw %%dx,%%ax" : "=a" (value) : "d" (port));
59 return value;
62 static inline unsigned long inl(int port)
64 unsigned long value;
65 asm volatile ("inl %%dx,%%eax" : "=a" (value) : "d" (port));
66 return value;
69 #endif