Corrected a struct packing issue with the new rl8168_header struct. This was causing
incorrect packet headers and corruption.
Fixed issues with the bound annoations on the eth syscalls. Calling with a length of 0
was causing failures down the line. There is still an issue with user_mem_assert() but
this needs to be addressed with an additional commit.
Fixed problems with sys_run_binary() syscall. With the annotations the original user space
addr was being referenced. However, that addr was not mapped in the new enviorment. Reverted
back to a kmalloc'd addr.
/** @file
- * @brief NE2K Driver Sketch
+ * @brief RL8168 Driver
*
* EXPERIMENTAL. DO NOT USE IF YOU DONT KNOW WHAT YOU ARE DOING
*
- * This driver will attempt to detect a ne2k device and run some interrupt
- * tests. This is used for ioapic debugging in simulation
+ * See Info below
*
* @author Paul Pearce <pearce@eecs.berkeley.edu>
*
- * @todo Everything
*/
#ifdef __SHARC__
* TODO: CONCURRENCY!
*/
+// This is to make it simply compile when not in __NETWORK__ mode.
#ifndef USER_MAC_ADDRESS
#define USER_MAC_ADDRESS {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
#endif
// Hacky stuff for syscall hack. Go away.
int packet_waiting;
int packet_buffer_size;
-char *CT(packet_buffer_size) packet_buffer;
+char *CT(MAX_FRAME_SIZE - PACKET_HEADER_SIZE) packet_buffer;
char *CT(MAX_FRAME_SIZE) packet_buffer_orig;
int packet_buffer_pos = 0;
// End hacky stuff
struct ETH_Header eth_head;
struct IP_Header ip_head;
struct UDP_Header udp_head;
-};
+} __attribute__((packed));
struct rl8168_packet {
struct rl8168_header rl8168_head;
void*DANGEROUS arg, size_t len) {
uint8_t *CT(len) checked_binary_buf;
checked_binary_buf = user_mem_assert(e, binary_buf, len, PTE_USER_RO);
-#if 0
- zra: copied into new address space, so no copy needed here.
+
uint8_t* new_binary = kmalloc(len, 0);
if(new_binary == NULL)
return -ENOMEM;
memcpy(new_binary, checked_binary_buf, len);
-#endif
- env_t* env = env_create(checked_binary_buf, len);
- //kfree(new_binary);
+ env_t* env = env_create(new_binary, len);
+ kfree(new_binary);
proc_set_state(env, PROC_RUNNABLE_S);
schedule_proc(env);
sys_yield(e);
if (eth_up) {
+ if (len == 0)
+ return 0;
+
char *COUNT(len) _buf = user_mem_assert(e, buf, len, PTE_U);
int total_sent = 0;
int just_sent = 0;
extern char*CT(packet_buffer_size) packet_buffer;
extern char*CT(MAX_FRAME_SIZE) packet_buffer_orig;
extern int packet_buffer_pos;
+
+ if (len == 0)
+ return 0;
+
char *CT(len) _buf = user_mem_assert(e, buf,len, PTE_U);
if (packet_waiting == 0)
* Write the message defined in buffer out across the channel, and wait for a response.
* Caller is responsible for management of both the buffer passed in and the buffer ptr returned.
*/
-response_t *send_message(char *msg, int len, syscall_id_t id);
+response_t *send_message(char *COUNT(len) msg, int len, syscall_id_t id);
/* write_to_channel()
* Send a message out over the channel, defined by msg, of length len
*/
-int write_to_channel(char *msg, int len);
+int write_to_channel(char *COUNT(len) msg, int len);
#endif //_NEWLIB_LIBC_WRAPPERS_H_
uint16_t sys_cgetc(void);
ssize_t sys_serial_write(void* buf, size_t len);
ssize_t sys_serial_read(void* buf, size_t len);
-ssize_t sys_eth_write(void* buf, size_t len);
-ssize_t sys_eth_read(void* buf, size_t len);
+ssize_t sys_eth_write(void *COUNT(len) buf, size_t len);
+ssize_t sys_eth_read(void *COUNT(len) buf, size_t len);
ssize_t sys_run_binary(void* binary_buf, void* arg, size_t len);
int sys_getpid(void);
size_t sys_getcpuid(void);
//Write a buffer over ethernet
ssize_t sys_eth_write(void* buf, size_t len)
{
+ if (len == 0)
+ return 0;
+
return syscall(SYS_eth_write, (intreg_t)buf, len, 0, 0, 0);
}
//Read a buffer via ethernet
ssize_t sys_eth_read(void* buf, size_t len)
{
+ if (len == 0)
+ return 0;
+
return syscall(SYS_eth_read, (intreg_t)buf, len, 0, 0, 0);
}