Subversion Repositories HelenOS

Rev

Rev 3597 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3597 Rev 4377
Line 34... Line 34...
34
 
34
 
35
#ifndef KERN_ia64_ASM_H_
35
#ifndef KERN_ia64_ASM_H_
36
#define KERN_ia64_ASM_H_
36
#define KERN_ia64_ASM_H_
37
 
37
 
38
#include <config.h>
38
#include <config.h>
-
 
39
#include <typedefs.h>
39
#include <arch/types.h>
40
#include <arch/types.h>
40
#include <arch/register.h>
41
#include <arch/register.h>
41
 
42
 
42
typedef uint64_t ioport_t;
-
 
43
 
-
 
44
#define IA64_IOSPACE_ADDRESS 0xE001000000000000ULL
43
#define IA64_IOSPACE_ADDRESS 0xE001000000000000ULL
45
 
44
 
46
static inline void  outb(ioport_t port,uint8_t v)
45
static inline void pio_write_8(ioport8_t *port, uint8_t v)
47
{
46
{
-
 
47
    uintptr_t prt = (uintptr_t) port;
-
 
48
 
-
 
49
    *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
48
    *((uint8_t *)(IA64_IOSPACE_ADDRESS + ( (port & 0xfff) | ( (port >> 2) << 12 )))) = v;
50
        ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
49
 
51
 
50
    asm volatile ("mf\n" ::: "memory");
52
    asm volatile ("mf\n" ::: "memory");
51
}
53
}
52
 
54
 
53
static inline void  outw(ioport_t port,uint16_t v)
55
static inline void pio_write_16(ioport16_t *port, uint16_t v)
54
{
56
{
-
 
57
    uintptr_t prt = (uintptr_t) port;
-
 
58
 
-
 
59
    *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
55
    *((uint16_t *)(IA64_IOSPACE_ADDRESS + ( (port & 0xfff) | ( (port >> 2) << 12 )))) = v;
60
        ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
56
 
61
 
57
    asm volatile ("mf\n" ::: "memory");
62
    asm volatile ("mf\n" ::: "memory");
58
}
63
}
59
 
64
 
60
static inline void  outl(ioport_t port,uint32_t v)
65
static inline void pio_write_32(ioport32_t *port, uint32_t v)
61
{
66
{
-
 
67
    uintptr_t prt = (uintptr_t) port;
-
 
68
 
-
 
69
    *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
62
    *((uint32_t *)(IA64_IOSPACE_ADDRESS + ( (port & 0xfff) | ( (port >> 2) << 12 )))) = v;
70
        ((prt & 0xfff) | ((prt >> 2) << 12)))) = v;
63
 
71
 
64
    asm volatile ("mf\n" ::: "memory");
72
    asm volatile ("mf\n" ::: "memory");
65
}
73
}
66
 
74
 
67
 
-
 
68
 
-
 
69
static inline uint8_t inb(ioport_t port)
75
static inline uint8_t pio_read_8(ioport8_t *port)
70
{
76
{
-
 
77
    uintptr_t prt = (uintptr_t) port;
-
 
78
 
71
    asm volatile ("mf\n" ::: "memory");
79
    asm volatile ("mf\n" ::: "memory");
72
 
80
 
-
 
81
    return *((ioport8_t *)(IA64_IOSPACE_ADDRESS +
73
    return *((uint8_t *)(IA64_IOSPACE_ADDRESS + ( (port & 0xfff) | ( (port >> 2) << 12 ))));
82
        ((prt & 0xfff) | ((prt >> 2) << 12))));
74
}
83
}
75
 
84
 
76
static inline uint16_t inw(ioport_t port)
85
static inline uint16_t pio_read_16(ioport16_t *port)
77
{
86
{
-
 
87
    uintptr_t prt = (uintptr_t) port;
-
 
88
 
78
    asm volatile ("mf\n" ::: "memory");
89
    asm volatile ("mf\n" ::: "memory");
79
 
90
 
-
 
91
    return *((ioport16_t *)(IA64_IOSPACE_ADDRESS +
80
    return *((uint16_t *)(IA64_IOSPACE_ADDRESS + ( (port & 0xffE) | ( (port >> 2) << 12 ))));
92
        ((prt & 0xfff) | ((prt >> 2) << 12))));
81
}
93
}
82
 
94
 
83
static inline uint32_t inl(ioport_t port)
95
static inline uint32_t pio_read_32(ioport32_t *port)
84
{
96
{
-
 
97
    uintptr_t prt = (uintptr_t) port;
-
 
98
 
85
    asm volatile ("mf\n" ::: "memory");
99
    asm volatile ("mf\n" ::: "memory");
86
 
100
 
-
 
101
    return *((ioport32_t *)(IA64_IOSPACE_ADDRESS +
87
    return *((uint32_t *)(IA64_IOSPACE_ADDRESS + ( (port & 0xfff) | ( (port >> 2) << 12 ))));
102
        ((prt & 0xfff) | ((prt >> 2) << 12))));
88
}
103
}
89
 
104
 
90
 
-
 
91
 
-
 
92
/** Return base address of current stack
105
/** Return base address of current stack
93
 *
106
 *
94
 * Return the base address of the current stack.
107
 * Return the base address of the current stack.
95
 * The stack is assumed to be STACK_SIZE long.
108
 * The stack is assumed to be STACK_SIZE long.
96
 * The stack must start on page boundary.
109
 * The stack must start on page boundary.
Line 340... Line 353...
340
 
353
 
341
extern void cpu_halt(void);
354
extern void cpu_halt(void);
342
extern void cpu_sleep(void);
355
extern void cpu_sleep(void);
343
extern void asm_delay_loop(uint32_t t);
356
extern void asm_delay_loop(uint32_t t);
344
 
357
 
345
extern void switch_to_userspace(uintptr_t entry, uintptr_t sp, uintptr_t bsp, uintptr_t uspace_uarg, uint64_t ipsr, uint64_t rsc);
358
extern void switch_to_userspace(uintptr_t, uintptr_t, uintptr_t, uintptr_t,
-
 
359
    uint64_t, uint64_t);
346
 
360
 
347
#endif
361
#endif
348
 
362
 
349
/** @}
363
/** @}
350
 */
364
 */