Skip to content

Commit

Permalink
Merge pull request #227 from LudwigOrtmann/native_cleanup
Browse files Browse the repository at this point in the history
Native cleanup
  • Loading branch information
mehlis committed Oct 2, 2013
2 parents d46ac9d + 24b2cfd commit f34d10e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 23 deletions.
8 changes: 4 additions & 4 deletions cpu/native/include/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ void thread_yield(void);

extern void _native_sig_leave_tramp(void);
extern ucontext_t *_native_cur_ctx, *_native_isr_ctx;
extern unsigned int _native_saved_eip;
extern int _native_in_isr;
extern int _native_in_syscall;
extern int _native_sigpend;
extern volatile unsigned int _native_saved_eip;
extern volatile int _native_in_isr;
extern volatile int _native_in_syscall;
extern volatile int _native_sigpend;
#ifdef MODULE_UART0
#include <sys/select.h>
extern fd_set _native_rfds;
Expand Down
1 change: 0 additions & 1 deletion cpu/native/include/nativenet_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct rx_buffer_s {
};

extern struct rx_buffer_s _nativenet_rx_buffer[];
extern volatile uint8_t rx_buffer_next;

void _nativenet_handle_packet(radio_packet_t *packet);
#endif /* NATIVENET_INTERNAL_H */
17 changes: 9 additions & 8 deletions cpu/native/irq_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <err.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>

// __USE_GNU for gregs[REG_EIP] access under Linux
#define __USE_GNU
Expand All @@ -25,21 +26,21 @@
#include "irq.h"
#include "cpu.h"

#define ENABLE_DEBUG (0)
#include "debug.h"

static int native_interrupts_enabled;
volatile int native_interrupts_enabled;

int _native_sigpend;
int _native_in_isr;
int _native_in_syscall;
static ucontext_t native_isr_context;
volatile int _native_sigpend;
volatile int _native_in_isr;
volatile int _native_in_syscall;
ucontext_t native_isr_context;
static sigset_t native_sig_set;
static char __isr_stack[SIGSTKSZ];
extern volatile tcb_t *active_thread;

unsigned int _native_saved_eip;
volatile unsigned int _native_saved_eip;
ucontext_t *_native_cur_ctx, *_native_isr_ctx;
int _native_in_isr;

static int pipefd[2];

Expand Down Expand Up @@ -261,7 +262,7 @@ int _native_popsig(void)
i = 0;

_native_in_syscall = 1;
while ((nleft > 0) && ((nread = read(pipefd[0], &sig + i, nleft)) != -1)) {
while ((nleft > 0) && ((nread = read(pipefd[0], ((uint8_t*)&sig) + i, nleft)) != -1)) {
i += nread;
nleft -= nread;
}
Expand Down
6 changes: 3 additions & 3 deletions cpu/native/native_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

extern volatile tcb_t *active_thread;
static ucontext_t end_context;
static char __isr_stack[SIGSTKSZ];
static char __end_stack[SIGSTKSZ];

#ifdef MODULE_UART0
fd_set _native_rfds;
Expand Down Expand Up @@ -135,11 +135,11 @@ void native_cpu_init()
err(1, "end_context(): getcontext()");
}

end_context.uc_stack.ss_sp = __isr_stack;
end_context.uc_stack.ss_sp = __end_stack;
end_context.uc_stack.ss_size = SIGSTKSZ;
end_context.uc_stack.ss_flags = 0;
makecontext(&end_context, sched_task_exit, 0);

puts("RIOT native cpu initialized.");
DEBUG("RIOT native cpu initialized.");
}
/** @} */
5 changes: 3 additions & 2 deletions cpu/native/net/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct nativenet_callback_s {
static struct nativenet_callback_s _nativenet_callbacks[255];

struct rx_buffer_s _nativenet_rx_buffer[RX_BUF_SIZE];
volatile uint8_t rx_buffer_next;
static volatile uint8_t rx_buffer_next;

uint8_t _native_net_chan;
uint16_t _native_net_pan;
Expand Down Expand Up @@ -108,7 +108,7 @@ radio_address_t nativenet_get_address()
uint8_t nativenet_send(radio_packet_t *packet)
{
packet->src = _native_net_addr;
DEBUG("nativenet_send: Sending packet of length %"PRIu16" from %"PRIu16" to %"PRIu16": %s\n", packet->length, packet->src, packet->dst, (char*) packet->data);
DEBUG("nativenet_send: Sending packet of length %"PRIu16" from %"PRIu16" to %"PRIu16"\n", packet->length, packet->src, packet->dst);

if (send_buf(packet) == -1) {
warnx("nativenet_send: error sending packet");
Expand Down Expand Up @@ -183,6 +183,7 @@ void _nativenet_handle_packet(radio_packet_t *packet)
}

/* copy packet to rx buffer */
DEBUG("\n\t\trx_buffer_next: %i\n\n", rx_buffer_next);
memcpy(&_nativenet_rx_buffer[rx_buffer_next].data, packet->data, packet->length);
memcpy(&_nativenet_rx_buffer[rx_buffer_next].packet, packet, sizeof(radio_packet_t));
_nativenet_rx_buffer[rx_buffer_next].packet.data = (uint8_t *) &_nativenet_rx_buffer[rx_buffer_next].data;
Expand Down
10 changes: 6 additions & 4 deletions cpu/native/net/tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void _native_handle_tap_input(void)
p.rssi = 0;
p.lqi = 0;
p.data = frame.field.payload.data;
DEBUG("_native_handle_tap_input: received packet of length %"PRIu16" for %"PRIu16" from %"PRIu16": %s\n", p.length, p.dst, p.src, (char*) p.data);
DEBUG("_native_handle_tap_input: received packet of length %"PRIu16" for %"PRIu16" from %"PRIu16"\n", p.length, p.dst, p.src);
_nativenet_handle_packet(&p);
}
}
Expand All @@ -103,7 +103,7 @@ int _native_marshall_ethernet(uint8_t *framebuf, radio_packet_t *packet)
unsigned char addr[ETHER_ADDR_LEN];

f = (union eth_frame*)framebuf;
addr[0] = addr[1] = addr[2] = addr[3] = addr[4] = addr[5] = (char)0xFF;
addr[0] = addr[1] = addr[2] = addr[3] = addr[4] = addr[5] = 0xFF;

memcpy(f->field.header.ether_dhost, addr, ETHER_ADDR_LEN);
memcpy(f->field.header.ether_shost, _native_tap_mac, ETHER_ADDR_LEN);
Expand Down Expand Up @@ -134,7 +134,9 @@ int send_buf(radio_packet_t *packet)
uint8_t buf[TAP_BUFFER_LENGTH];
int nsent, to_send;

DEBUG("send_buf: Sending packet of length %"PRIu16" from %"PRIu16" to %"PRIu16": %s\n", packet->length, packet->src, packet->dst, (char*) packet->data);
memset(buf, 0, sizeof(buf));

DEBUG("send_buf: Sending packet of length %"PRIu16" from %"PRIu16" to %"PRIu16"\n", packet->length, packet->src, packet->dst);
to_send = _native_marshall_ethernet(buf, packet);

DEBUG("send_buf: trying to send %d bytes\n", to_send);
Expand Down Expand Up @@ -220,7 +222,7 @@ int tap_init(char *name)
}
#endif /* OSX */

puts("RIOT native tap initialized.");
DEBUG("RIOT native tap initialized.\n");
return _native_tap_fd;
}
/** @} */
2 changes: 1 addition & 1 deletion cpu/native/rtc/posix-rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "debug.h"

#include <rtc.h>
#include "rtc.h"

static int native_rtc_enabled;

Expand Down

0 comments on commit f34d10e

Please sign in to comment.