Skip to content

Commit f7cd383

Browse files
committed
Merge branch 'dev' of github.com:hioa-cs/IncludeOS into dev
2 parents 6ff8591 + 19fcbf1 commit f7cd383

67 files changed

Lines changed: 3284 additions & 796 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/arch

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#ifndef INCLUDEOS_ARCH_HEADER
2121
#define INCLUDEOS_ARCH_HEADER
2222

23-
#define ARCH_X86
2423
#include <cstddef>
2524
#include <cstdint>
2625

@@ -36,6 +35,11 @@ inline uint64_t __arch_cpu_cycles() noexcept {
3635
asm("rdtsc" : "=A" (ret));
3736
return ret;
3837
}
38+
#else
39+
inline uint64_t __arch_cpu_cycles() noexcept {
40+
return 0;
41+
}
3942
#endif
4043

4144
#endif
45+

api/common

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,11 @@
5353
#undef Expects
5454
#undef Ensures
5555

56-
#define Expects(cond) \
57-
do { \
58-
if (UNLIKELY(not (cond))) { \
59-
std::cerr << "OS: Precondition (" OS_STRINGIFY(cond) \
60-
<< ") failed...\n" << "\t...in function: " \
61-
<< __func__ << " @" << __FILE__ << ":" \
62-
<< __LINE__ << '\n'; \
63-
std::terminate(); \
64-
} \
65-
} while(0)
56+
#define Expects(cond) \
57+
assert(LIKELY(cond) && "OS: Precondition failed")
6658

67-
#define Ensures(cond) \
68-
do { \
69-
if (UNLIKELY(not (cond))) { \
70-
std::cerr << "OS: Postcondition (" OS_STRINGIFY(cond) \
71-
<< ") failed...\n" << "\t...in function: " \
72-
<< __func__ << " @" << __FILE__ << ":" \
73-
<< __LINE__ << '\n'; \
74-
std::terminate(); \
75-
} \
76-
} while(0)
59+
#define Ensures(cond) \
60+
assert(LIKELY(cond) && "OS: Postcondition failed")
7761

7862
#endif //< defined(OS_TERMINATE_ON_CONTRACT_VIOLATION)
7963

api/hw/ioport.hpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
88
// You may obtain a copy of the License at
9-
//
9+
//
1010
// http://www.apache.org/licenses/LICENSE-2.0
11-
//
11+
//
1212
// Unless required by applicable law or agreed to in writing, software
1313
// distributed under the License is distributed on an "AS IS" BASIS,
1414
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -28,9 +28,12 @@ namespace hw {
2828
static inline uint8_t inb(int port)
2929
{
3030
int ret;
31+
#ifdef ARCH_X86
3132
__asm__ volatile ("xorl %eax,%eax");
3233
__asm__ volatile ("inb %%dx,%%al":"=a" (ret):"d"(port));
33-
34+
#else
35+
#warning "inb() not implemented for selected arch"
36+
#endif
3437
return ret;
3538
}
3639

@@ -39,7 +42,11 @@ namespace hw {
3942
@param data : One byte of data to send to @param port
4043
*/
4144
static inline void outb(int port, uint8_t data) {
45+
#ifdef ARCH_X86
4246
__asm__ volatile ("outb %%al,%%dx"::"a" (data), "d"(port));
47+
#else
48+
#warning "outb() not implemented for selected arch"
49+
#endif
4350
}
4451

4552
/** Receive a word from port.
@@ -48,9 +55,12 @@ namespace hw {
4855
static inline uint16_t inw(int port)
4956
{
5057
int ret;
58+
#ifdef ARCH_X86
5159
__asm__ volatile ("xorl %eax,%eax");
5260
__asm__ volatile ("inw %%dx,%%ax":"=a" (ret):"d"(port));
53-
61+
#else
62+
#warning "inw() not implemented for selected arch"
63+
#endif
5464
return ret;
5565
}
5666

@@ -59,9 +69,14 @@ namespace hw {
5969
@param data : One word of data to send to @param port
6070
*/
6171
static inline void outw(int port, uint16_t data) {
72+
#ifdef ARCH_X86
6273
__asm__ volatile ("outw %%ax,%%dx"::"a" (data), "d"(port));
74+
#else
75+
#warning "outw() not implemented for selected arch"
76+
#endif
6377
}
6478

6579
} //< namespace hw
6680

6781
#endif // HW_IOPORT_HPP
82+

api/hw/pci.hpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,49 +28,73 @@ namespace hw {
2828
static inline uint8_t inp(port_t port)
2929
{
3030
uint8_t ret;
31-
31+
#ifdef ARCH_X86
3232
__asm__ volatile("xorl %eax,%eax");
3333
__asm__ volatile("inb %%dx,%%al"
3434
:"=a"(ret)
3535
:"d"(port));
36-
return ret;
36+
#else
37+
#warning "inp() not implemented for selected arch"
38+
#endif
39+
return ret;
3740
}
3841

3942
static inline uint16_t inpw(port_t port)
4043
{
4144
uint16_t ret;
45+
#ifdef ARCH_X86
4246
__asm__ volatile("xorl %eax,%eax");
4347
__asm__ volatile("inw %%dx,%%ax"
4448
:"=a"(ret)
4549
:"d"(port));
46-
return ret;
50+
#else
51+
#warning "inpw() not implemented for selected arch"
52+
#endif
53+
return ret;
4754
}
4855

4956
static inline uint32_t inpd(port_t port)
5057
{
5158
uint32_t ret;
59+
#ifdef ARCH_X86
5260
__asm__ volatile("xorl %eax,%eax");
5361
__asm__ volatile("inl %%dx,%%eax"
5462
:"=a"(ret)
5563
:"d"(port));
56-
64+
#else
65+
#warning "inpd() not implemented for selected arch"
66+
#endif
67+
5768
return ret;
5869
}
5970

6071

6172
static inline void outp(port_t port, uint8_t data)
6273
{
74+
#ifdef ARCH_X86
6375
__asm__ volatile ("outb %%al,%%dx"::"a" (data), "d"(port));
76+
#else
77+
#warning "outp() not implemented for selected arch"
78+
#endif
6479
}
6580
static inline void outpw(port_t port, uint16_t data)
6681
{
82+
#ifdef ARCH_X86
6783
__asm__ volatile ("outw %%ax,%%dx"::"a" (data), "d"(port));
84+
#else
85+
#warning "outpw() not implemented for selected arch"
86+
#endif
6887
}
6988
static inline void outpd(port_t port, uint32_t data)
7089
{
90+
#ifdef ARCH_X86
7191
__asm__ volatile ("outl %%eax,%%dx"::"a" (data), "d"(port));
92+
#else
93+
#warning "outpd() not implemented for selected arch"
94+
#endif
7295
}
7396

7497
} //< namespace hw
7598

7699
#endif
100+

0 commit comments

Comments
 (0)