- first steps to realize a RCKPC driver

git-svn-id: http://svn.lfbs.rwth-aachen.de/svn/scc/trunk/MetalSVM@81 315a16e6-25f9-4109-90ae-ca3045a26c18
This commit is contained in:
stefan 2010-08-11 20:42:49 +00:00
parent cb7cbefb7f
commit 585d6d01cf
4 changed files with 125 additions and 22 deletions

14
drivers/Makefile Normal file
View file

@ -0,0 +1,14 @@
SUBDIRS = net
default:
for i in $(SUBDIRS); do $(MAKE) -C $$i default; done
all:
for i in $(SUBDIRS); do $(MAKE) -C $$i all; done
clean:
for i in $(SUBDIRS); do $(MAKE) -C $$i clean; done
depend:
for i in $(SUBDIRS); do $(MAKE) -C $$i depend; done

21
drivers/net/Makefile Normal file
View file

@ -0,0 +1,21 @@
C_source = sccpc.c
OBJS += $(patsubst %.c, %.o, $(filter %.c, $(C_source)))
ALLOBJS += $(patsubst %.c, %.o, $(filter %.c, $(C_source)))
# other implicit rules
%.o : %.c
$(CC) -c $(CFLAGS) -o $@ $<
default: $(OBJS)
all: $(OBJS)
clean:
$(RM) *.o *~ $(NAME)
depend:
$(CC) -MM $(CFLAGS) $(C_source) > Makefile.dep
-include Makefile.dep
# DO NOT DELETE

65
drivers/net/sccpc.c Normal file
View file

@ -0,0 +1,65 @@
/*
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
* RWTH Aachen University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of MetalSVM.
*/
#include <metalsvm/stddef.h>
#include <metalsvm/stdio.h>
#include <metalsvm/string.h>
#ifdef CONFIG_LWIP
#include <lwip/sys.h>
#include <lwip/stats.h>
#include <lwip/netif.h>
#include <netif/etharp.h>
static struct netif *mynetif;
/**
*
*
* @return error code
* - ERR_OK: packet transferred to hardware
* - ERR_CONN: no link or link failure
* - ERR_IF: could not transfer to link (hardware buffer full?)
*/
static err_t sccpc_output(struct netif *netif, struct pbuf *p)
{
return ERR_CONN;
}
err_t sccpcif_init(struct netif* netif)
{
mynetif = netif;
/* administrative details */
mynetif->name[0] = 'p';
mynetif->name[1] = 'c';
mynetif->num = 0;
/* downward functions */
mynetif->output = ip_output;
mynetif->linkoutput = sccpc_output;
/* maximum transfer unit */
mynetif->mtu = 1500;
/* broadcast capability */
mynetif->flags = NETIF_FLAG_LINK_UP;
/* hardware address length */
mynetif->hwaddr_len = 6;
return ERR_OK;
}
#endif

View file

@ -37,25 +37,33 @@
#include <lwip/dhcp.h>
#include <lwip/netif.h>
#include <netif/etharp.h>
//#include <drivers/pcnet.h>
#endif
#ifdef CONFIG_ROCKCREEK
#include <asm/scc.h>
#endif
extern int test_init(void);
extern const void kernel_start;
extern const void kernel_end;
#ifdef CONFIG_LWIP
int STDCALL lwip_task(void* arg)
#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK)
err_t sccpcif_init(struct netif* netif);
int STDCALL scc_pc_task(void* arg)
{
struct netif netif;
struct ip_addr ipaddr;
struct ip_addr netmask;
struct ip_addr gw;
err_t err;
sleep(10);
kputs("LWIP task is started\n");
/* Set network address variables */
IP4_ADDR(&gw, 192,168,1,254);
IP4_ADDR(&ipaddr, 192,168,1,scc_info.pid+1);
IP4_ADDR(&netmask, 255,255,255,0);
stats_init(); /* Clears the structure where runtime statistics are gathered */
sys_init();
mem_init(); /* Initializes the dynamic memory heap defined by MEM_SIZE. */
@ -67,25 +75,20 @@ int STDCALL lwip_task(void* arg)
tcp_init(); /* Clears the TCP PCB list and clears some internal TCP timers. */
/* Bring up the network interface */
//if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, pcnetif_init, ethernet_input)) {
// kputs("Unable to add network interface\n");
// return NULL;
//}
if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, sccpcif_init, ip_input)) {
kputs("Unable to add network interface\n");
return -1;
}
/* This will bring the interface up and set its IP address when it can acquire one. */
//err = dhcp_start(&netif);
//if (err != ERR_OK) {
// kprintf("Unable to get IP via DHCP: %s\n", lwip_strerr(err));
// return NULL;
//}
netif_set_default(&netif);
//if (netif_is_up(&netif)) {
// kputs("Network interface is not up\n");
// return NULL;
//}
if (netif_is_up(&netif)) {
kputs("Network interface is not up\n");
return -1;
}
//while(1) {
//}
while(1) {
}
return 0;
}
@ -94,7 +97,7 @@ int STDCALL lwip_task(void* arg)
int main(void)
{
#ifdef CONFIG_LWIP
tid_t lwip_id;
tid_t pc_id;
#endif
kprintf("Here is MetalSVM %s\n", METALSVM_VERSION);
@ -128,7 +131,7 @@ int main(void)
test_init();
#ifdef CONFIG_LWIP
//create_kernel_task(&lwip_id, lwip_task, NULL);
create_kernel_task(&pc_id, scc_pc_task, NULL);
#endif
current_task->status = TASK_IDLE;