Create Open firmware pseudo driver.
Change ofnet.c to disknet.c and remove almost all ieee1275 specific code. Create grub_net_malloc to handle iee1275 memory issues in a temporary solution.
This commit is contained in:
parent
9a9cee4e43
commit
87fdc7e8d2
15 changed files with 272 additions and 190 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
kernel_img_HEADERS += ieee1275/ieee1275.h \
|
||||
command.h i18n.h env_private.h net/ip.h net/udp.h net/ethernet.h net/arp.h net/tftp.h\
|
||||
net/ieee1275/interface.h net/type_net.h net.h net/interface.h net/protocol.h net/netbuff.h
|
||||
net/ieee1275/interface.h net/type_net.h net.h net/interface.h net/protocol.h net/netbuff.h net/mem.h
|
||||
|
||||
# Programs
|
||||
pkglib_PROGRAMS = kernel.img
|
||||
|
@ -23,8 +23,8 @@ kernel_img_SOURCES = kern/powerpc/ieee1275/startup.S kern/ieee1275/cmain.c \
|
|||
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
|
||||
kern/generic/millisleep.c kern/time.c \
|
||||
symlist.c kern/$(target_cpu)/cache.S net/ip.c net/tftp.c net/udp.c net/ethernet.c net/arp.c \
|
||||
net/ieee1275/interface.c net/interface.c net/protocol.c net/netbuff.c \
|
||||
fs/ieee1275/ofnet.c
|
||||
net/drivers/ieee1275/ofdriver.c net/interface.c net/protocol.c net/netbuff.c \
|
||||
fs/netdisk.c net/ieee1275/mem.c
|
||||
kernel_img_CFLAGS = $(COMMON_CFLAGS)
|
||||
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
|
||||
kernel_img_LDFLAGS += $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x200000,-Bstatic
|
||||
|
|
|
@ -23,26 +23,25 @@
|
|||
#include <grub/file.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/net/arp.h>
|
||||
#include <grub/net/ip.h>
|
||||
#include <grub/net/udp.h>
|
||||
#include <grub/net/tftp.h>
|
||||
#include <grub/net/ethernet.h>
|
||||
#include <grub/net/protocol.h>
|
||||
#include <grub/net/interface.h>
|
||||
#include <grub/bufio.h>
|
||||
#include <grub/ieee1275/ofnet.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/net/ieee1275/interface.h>
|
||||
#include <grub/net/mem.h>
|
||||
#include <grub/net/disknet.h>
|
||||
|
||||
struct grub_net_card *grub_net_cards = NULL;
|
||||
struct grub_net_network_layer_interface *grub_net_network_layer_interfaces = NULL;
|
||||
struct grub_net_route *grub_net_routes = NULL;
|
||||
|
||||
#define BUFFERADDR 0X00000000
|
||||
#define BUFFERSIZE 0x02000000
|
||||
#define U64MAXSIZE 18446744073709551615ULL
|
||||
|
||||
|
||||
//static grub_ieee1275_ihandle_t handle = 0;
|
||||
|
||||
static const char *
|
||||
find_sep (const char *name)
|
||||
{
|
||||
|
@ -295,29 +294,45 @@ grub_ofnetfs_open (struct grub_file *file , const char *name )
|
|||
|
||||
return 1;
|
||||
}
|
||||
// grub_printf("name = %s\n",name);
|
||||
|
||||
/*TESt*/
|
||||
// grub_printf("name = %s\n",name);
|
||||
struct grub_net_card *card;
|
||||
struct grub_ofnetcard_data *ofdata;
|
||||
FOR_NET_CARDS(card)
|
||||
{
|
||||
grub_printf("card address = %x\n", (int) card);
|
||||
grub_printf ("card name = %s\n", card->name);
|
||||
ofdata = card->data;
|
||||
grub_printf("card path = %s\n", (char *) ofdata->path);
|
||||
grub_printf("card handle = %d\n", ofdata->handle);
|
||||
}
|
||||
grub_printf("card list address in disknet.c = %x\n",(int) grub_net_cards);
|
||||
card = grub_net_cards;
|
||||
grub_printf("card address = %x\n", (int) card);
|
||||
/*TESt*/
|
||||
|
||||
struct grub_net_protocol_stack *stack;
|
||||
struct grub_net_buff *pack;
|
||||
struct grub_net_application_transport_interface *app_interface;
|
||||
int file_size;
|
||||
char *datap;
|
||||
int amount = 0;
|
||||
grub_addr_t found_addr;
|
||||
grub_netdisk_data_t netdisk_data = (grub_netdisk_data_t) file->device->disk->data;
|
||||
|
||||
// TODO: replace getting IP and MAC from bootp by routing functions
|
||||
struct grub_net_network_layer_interface net_interface;
|
||||
struct grub_net_card net_card;
|
||||
struct grub_net_addr ila, lla;
|
||||
ila.addr = (grub_uint8_t *) &(bootp_pckt->yiaddr);
|
||||
ila.addr = (grub_uint8_t *) & (bootp_pckt->yiaddr);
|
||||
ila.len = 4;
|
||||
lla.addr = (grub_uint8_t *) &(bootp_pckt->chaddr);
|
||||
lla.addr = (grub_uint8_t *) & (bootp_pckt->chaddr);
|
||||
lla.len = 6;
|
||||
net_card.ila = &ila;
|
||||
net_card.lla = &lla;
|
||||
net_interface.card = &net_card;
|
||||
// END TODO
|
||||
|
||||
card->ila = &ila;
|
||||
card->lla = &lla;
|
||||
net_interface.card = card;
|
||||
|
||||
if(! netdisk_data)
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "arguments missing");
|
||||
|
||||
|
@ -328,37 +343,35 @@ grub_ofnetfs_open (struct grub_file *file , const char *name )
|
|||
|
||||
app_interface = (struct grub_net_application_transport_interface *) stack->interface;
|
||||
app_interface->inner_layer->data = (void *) &(netdisk_data->server_ip);
|
||||
|
||||
pack = grub_netbuff_alloc (2048);
|
||||
grub_netbuff_reserve (pack,2048);
|
||||
|
||||
file_size = app_interface->app_prot->get_file_size(&net_interface,stack,pack,(char *) name);
|
||||
|
||||
for (found_addr = 0x800000; found_addr < + 2000 * 0x100000; found_addr += 0x100000)
|
||||
{
|
||||
if (grub_claimmap (found_addr , file_size) != -1)
|
||||
break;
|
||||
}
|
||||
file->data = (void *) found_addr;
|
||||
file->data = grub_net_malloc (file_size);
|
||||
|
||||
grub_netbuff_clear(pack);
|
||||
grub_netbuff_reserve (pack,2048);
|
||||
|
||||
app_interface->app_prot->open (&net_interface,stack,pack,(char *) name);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
goto error;
|
||||
|
||||
do
|
||||
{
|
||||
grub_netbuff_clear(pack);
|
||||
grub_netbuff_reserve (pack,2048);
|
||||
app_interface->app_prot->recv (&net_interface,stack,pack);
|
||||
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
goto error;
|
||||
|
||||
if ((pack->tail - pack->data))
|
||||
{
|
||||
// file->data = grub_realloc(file->data,amount + pack->tail - pack->data);
|
||||
datap = (char *)file->data + amount;
|
||||
amount += (pack->tail - pack->data);
|
||||
grub_memcpy(datap , pack->data, pack->tail - pack->data);
|
||||
grub_memcpy (datap , pack->data, pack->tail - pack->data);
|
||||
}
|
||||
|
||||
grub_netbuff_clear(pack);
|
||||
grub_netbuff_reserve (pack,2048);
|
||||
app_interface->app_prot->send_ack (&net_interface,stack,pack);
|
||||
|
@ -394,54 +407,6 @@ static struct grub_fs grub_ofnetfs_fs =
|
|||
.next = 0
|
||||
};
|
||||
|
||||
static char *
|
||||
grub_ieee1275_get_devargs (const char *path)
|
||||
{
|
||||
int len;
|
||||
char *colon = grub_strchr (path, ':');
|
||||
len = colon - path;
|
||||
if (! colon)
|
||||
return 0;
|
||||
|
||||
return grub_strndup (path,len);
|
||||
}
|
||||
|
||||
static int
|
||||
grub_ofnet_detect (void)
|
||||
{
|
||||
|
||||
char *devalias;
|
||||
char bootpath[64]; /* XXX check length */
|
||||
grub_ieee1275_phandle_t root;
|
||||
grub_uint32_t net_type;
|
||||
|
||||
grub_ieee1275_finddevice ("/chosen", &grub_ieee1275_chosen);
|
||||
if (grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", &bootpath,
|
||||
sizeof (bootpath), 0))
|
||||
{
|
||||
/* Should never happen. */
|
||||
grub_printf ("/chosen/bootpath property missing!\n");
|
||||
return 0;
|
||||
}
|
||||
devalias = grub_ieee1275_get_aliasdevname (bootpath);
|
||||
|
||||
if (grub_strncmp(devalias ,"net",3))
|
||||
return 0;
|
||||
|
||||
grub_net = grub_malloc (sizeof *grub_net );
|
||||
grub_net->name = "net";
|
||||
grub_net->dev = grub_ieee1275_get_devargs (bootpath);
|
||||
grub_ieee1275_finddevice ("/", &root);
|
||||
grub_ieee1275_get_integer_property (root, "ibm,fw-net-compatibility",
|
||||
&net_type, sizeof net_type, 0);
|
||||
grub_printf("root = %d\n",root);
|
||||
grub_printf("net_type= %d\n",net_type);
|
||||
grub_net->type = net_type;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#define IPMASK 0x000000FF
|
||||
#define IPSIZE 16
|
||||
#define IPTEMPLATE "%d.%d.%d.%d"
|
||||
|
@ -456,34 +421,17 @@ grub_ip2str (grub_uint32_t ip)
|
|||
return str_ip;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
grub_get_netinfo (grub_ofnet_t netinfo,grub_bootp_t packet)
|
||||
grub_disknet_init(void)
|
||||
{
|
||||
netinfo->sip = grub_ip2str(packet->siaddr);
|
||||
netinfo->cip = grub_ip2str(packet->yiaddr);
|
||||
netinfo->gat = grub_ip2str(packet->giaddr);
|
||||
grub_printf("packet->siaddr = %x\n",packet->siaddr);
|
||||
grub_printf("netinfo-> = %s\n",netinfo->sip);
|
||||
grub_printf("packet->yiaddr = %x\n",packet->yiaddr);
|
||||
grub_printf("netinfo-> = %s\n",netinfo->cip);
|
||||
grub_printf("packet->giaddr = %x\n",packet->giaddr);
|
||||
grub_printf("netinfo-> = %s\n",netinfo->gat);
|
||||
|
||||
grub_disk_dev_register (&grub_ofnet_dev);
|
||||
grub_fs_register (&grub_ofnetfs_fs);
|
||||
}
|
||||
|
||||
void
|
||||
grub_ofnet_init(void)
|
||||
{
|
||||
tftp_ini ();
|
||||
bootp_pckt = grub_getbootp ();
|
||||
if(grub_ofnet_detect ())
|
||||
{
|
||||
grub_get_netinfo (grub_net, bootp_pckt );
|
||||
grub_disk_dev_register (&grub_ofnet_dev);
|
||||
grub_fs_register (&grub_ofnetfs_fs);
|
||||
card_open ();
|
||||
}
|
||||
}
|
||||
void
|
||||
grub_ofnet_fini(void)
|
||||
grub_disknet_fini(void)
|
||||
{
|
||||
grub_fs_unregister (&grub_ofnetfs_fs);
|
||||
grub_disk_dev_unregister (&grub_ofnet_dev);
|
|
@ -24,7 +24,6 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/machine/ieee1275.h>
|
||||
|
||||
/* Maps a device alias to a pathname. */
|
||||
struct grub_ieee1275_devalias
|
||||
{
|
||||
char *name;
|
||||
|
@ -65,6 +64,13 @@ struct grub_ieee1275_common_hdr
|
|||
typedef grub_uint32_t grub_ieee1275_ihandle_t;
|
||||
typedef grub_uint32_t grub_ieee1275_phandle_t;
|
||||
|
||||
struct grub_ofnetcard_data
|
||||
{
|
||||
char *path;
|
||||
grub_ieee1275_ihandle_t handle;
|
||||
};
|
||||
|
||||
/* Maps a device alias to a pathname. */
|
||||
extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen);
|
||||
extern grub_ieee1275_ihandle_t EXPORT_VAR(grub_ieee1275_mmu);
|
||||
extern int (* EXPORT_VAR(grub_ieee1275_entry_fn)) (void *);
|
||||
|
@ -186,4 +192,6 @@ int EXPORT_FUNC(grub_ieee1275_devices_iterate) (int (*hook)
|
|||
(struct grub_ieee1275_devalias *
|
||||
alias));
|
||||
char *EXPORT_FUNC(grub_ieee1275_get_aliasdevname) (const char *path);
|
||||
void EXPORT_FUNC(grub_ofnet_findcards) (void);
|
||||
void EXPORT_FUNC(grub_ofnet_probecards) (void);
|
||||
#endif /* ! GRUB_IEEE1275_HEADER */
|
||||
|
|
|
@ -23,32 +23,9 @@
|
|||
#include <grub/err.h>
|
||||
#include <grub/types.h>
|
||||
|
||||
extern void grub_ofnet_init(void);
|
||||
extern void grub_ofnet_fini(void);
|
||||
void grub_ofnet_init(void);
|
||||
void grub_ofnet_fini(void);
|
||||
|
||||
/*
|
||||
struct grub_net;
|
||||
|
||||
struct grub_net_dev
|
||||
{
|
||||
/ The device name. /
|
||||
const char *name;
|
||||
|
||||
/ FIXME: Just a template. /
|
||||
int (*probe) (struct grub_net *net, const void *addr);
|
||||
void (*reset) (struct grub_net *net);
|
||||
int (*poll) (struct grub_net *net);
|
||||
void (*transmit) (struct grub_net *net, const void *destip,
|
||||
unsigned srcsock, unsigned destsock, const void *packet);
|
||||
void (*disable) (struct grub_net *net);
|
||||
|
||||
/ The next net device. /
|
||||
struct grub_net_dev *next;
|
||||
};
|
||||
typedef struct grub_net_dev *grub_net_dev_t;
|
||||
|
||||
struct grub_fs;
|
||||
*/
|
||||
struct grub_ofnet
|
||||
{
|
||||
/* The net name. */
|
||||
|
@ -85,7 +62,7 @@ struct grub_bootp {
|
|||
char file [128]; /* Boot filename */
|
||||
// grub_uint32_t filesize ; /*File size (testing)*/
|
||||
unsigned char vend [64];
|
||||
};
|
||||
};
|
||||
|
||||
typedef struct grub_bootp* grub_bootp_t;
|
||||
|
||||
|
|
5
include/grub/net/disknet.h
Normal file
5
include/grub/net/disknet.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef GRUB_DISKNET_HEADER
|
||||
#define GRUB_DISKNET_HEADER 1
|
||||
void grub_disknet_init(void);
|
||||
void grub_disknet_fini(void);
|
||||
#endif /* ! GRUB_NET_HEADER */
|
|
@ -10,9 +10,18 @@ struct etherhdr
|
|||
grub_uint16_t type;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define PCP (x) x & 0xe000
|
||||
#define CFI (x) x & 0x1000
|
||||
#define VID (x) x & 0x0fff
|
||||
#define PCP(x) x & 0xe000
|
||||
#define CFI(x) x & 0x1000
|
||||
#define VID(x) x & 0x0fff
|
||||
#define PRINT_ETH_ADDR(name,addr) grub_printf("%s %x:%x:%x:%x:%x:%x\n",\
|
||||
name,\
|
||||
addr[0],\
|
||||
addr[1],\
|
||||
addr[2],\
|
||||
addr[3],\
|
||||
addr[4],\
|
||||
addr[5]\
|
||||
)
|
||||
|
||||
struct llchdr
|
||||
{
|
||||
|
|
|
@ -6,14 +6,5 @@
|
|||
#include <grub/ieee1275/ofnet.h>
|
||||
#include <grub/net/netbuff.h>
|
||||
|
||||
|
||||
grub_ofnet_t grub_net;
|
||||
|
||||
grub_bootp_t bootp_pckt;
|
||||
|
||||
int send_card_buffer (struct grub_net_buff *pack);
|
||||
int get_card_packet (struct grub_net_buff *pack);
|
||||
int card_open (void);
|
||||
int card_close (void);
|
||||
|
||||
#endif
|
||||
|
|
9
include/grub/net/mem.h
Normal file
9
include/grub/net/mem.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#ifndef GRUB_NETMM_H
|
||||
#define GRUB_NETMM_H 1
|
||||
|
||||
#include <grub/types.h>
|
||||
#include <grub/symbol.h>
|
||||
|
||||
void *EXPORT_FUNC(grub_net_malloc) (grub_size_t size);
|
||||
|
||||
#endif /* ! GRUB_MM_H */
|
|
@ -23,6 +23,10 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/ieee1275/ofnet.h>
|
||||
#include <grub/net/ieee1275/interface.h>
|
||||
#include <grub/net.h>
|
||||
#include <grub/net/disknet.h>
|
||||
#include <grub/net/tftp.h>
|
||||
|
||||
enum grub_ieee1275_parse_type
|
||||
{
|
||||
|
@ -490,3 +494,63 @@ grub_getbootp( void )
|
|||
return packet;
|
||||
}
|
||||
|
||||
void grub_ofnet_findcards (void)
|
||||
{
|
||||
struct grub_net_card *card;
|
||||
int i = 0;
|
||||
|
||||
auto int search_net_devices (struct grub_ieee1275_devalias *alias);
|
||||
|
||||
int search_net_devices (struct grub_ieee1275_devalias *alias)
|
||||
{
|
||||
if ( !grub_strcmp (alias->type,"network") )
|
||||
{
|
||||
|
||||
card = grub_malloc (sizeof (struct grub_net_card));
|
||||
struct grub_ofnetcard_data *ofdata = grub_malloc (sizeof (struct grub_ofnetcard_data));
|
||||
ofdata->path = grub_strdup (alias->path);
|
||||
card->data = ofdata;
|
||||
card->name = grub_xasprintf("eth%d",i++); // grub_strdup (alias->name);
|
||||
grub_net_card_register (card);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*Look at all nodes for devices of the type network*/
|
||||
grub_ieee1275_devices_iterate (search_net_devices);
|
||||
|
||||
}
|
||||
|
||||
void grub_ofnet_probecards (void)
|
||||
{
|
||||
struct grub_net_card *card;
|
||||
struct grub_net_card_driver *driver;
|
||||
|
||||
/*Assign correspondent driver for each device. */
|
||||
FOR_NET_CARDS (card)
|
||||
{
|
||||
FOR_NET_CARD_DRIVERS (driver)
|
||||
{
|
||||
if (driver->init(card) == GRUB_ERR_NONE)
|
||||
{
|
||||
card->driver = driver;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_ofnet_init(void)
|
||||
{
|
||||
|
||||
ofdriver_ini();
|
||||
grub_ofnet_findcards();
|
||||
grub_ofnet_probecards();
|
||||
|
||||
/*init tftp stack - will be handled by module subsystem in the future*/
|
||||
tftp_ini ();
|
||||
/*get bootp packet - won't be needed in the future*/
|
||||
bootp_pckt = grub_getbootp ();
|
||||
grub_disknet_init();
|
||||
}
|
||||
|
|
74
net/drivers/ieee1275/ofdriver.c
Normal file
74
net/drivers/ieee1275/ofdriver.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
#include <grub/net/netbuff.h>
|
||||
#include <grub/ieee1275/ofnet.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/net.h>
|
||||
|
||||
static
|
||||
grub_err_t card_open (struct grub_net_card *dev)
|
||||
{
|
||||
|
||||
struct grub_ofnetcard_data *data = dev->data;
|
||||
return grub_ieee1275_open (data->path,&(data->handle));
|
||||
}
|
||||
|
||||
static
|
||||
grub_err_t card_close (struct grub_net_card *dev)
|
||||
{
|
||||
|
||||
struct grub_ofnetcard_data *data = dev->data;
|
||||
|
||||
if (data->handle)
|
||||
grub_ieee1275_close (data->handle);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static
|
||||
grub_err_t send_card_buffer (struct grub_net_card *dev, struct grub_net_buff *pack)
|
||||
{
|
||||
|
||||
int actual;
|
||||
struct grub_ofnetcard_data *data = dev->data;
|
||||
|
||||
return grub_ieee1275_write (data->handle,pack->data,pack->tail - pack->data,&actual);
|
||||
}
|
||||
|
||||
static
|
||||
grub_err_t get_card_packet (struct grub_net_card *dev, struct grub_net_buff *pack)
|
||||
{
|
||||
|
||||
int actual, rc;
|
||||
struct grub_ofnetcard_data *data = dev->data;
|
||||
grub_netbuff_clear(pack);
|
||||
|
||||
do
|
||||
{
|
||||
rc = grub_ieee1275_read (data->handle,pack->data,1500,&actual);
|
||||
|
||||
}while (actual <= 0 || rc < 0);
|
||||
grub_netbuff_put (pack, actual);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static struct grub_net_card_driver ofdriver =
|
||||
{
|
||||
.name = "ofnet",
|
||||
.init = card_open,
|
||||
.fini = card_close,
|
||||
.send = send_card_buffer,
|
||||
.recv = get_card_packet
|
||||
|
||||
};
|
||||
|
||||
void ofdriver_ini(void)
|
||||
{
|
||||
grub_net_card_driver_register (&ofdriver);
|
||||
}
|
||||
|
||||
void ofdriver_fini(void)
|
||||
{
|
||||
grub_net_card_driver_unregister (&ofdriver);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -22,10 +22,10 @@ struct grub_net_addr target_addr, grub_uint16_t ethertype)
|
|||
eth = (struct etherhdr *) nb->data;
|
||||
grub_memcpy(eth->dst, target_addr.addr, target_addr.len);
|
||||
grub_memcpy(eth->src, bootp_pckt->chaddr, 6);
|
||||
|
||||
eth->type = ethertype;
|
||||
|
||||
return send_card_buffer(nb);
|
||||
// return inf->card->driver->send(inf->card,nb);
|
||||
return inf->card->driver->send (inf->card,nb);
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,12 +42,11 @@ grub_uint16_t ethertype)
|
|||
start_time = grub_get_time_ms();
|
||||
while (1)
|
||||
{
|
||||
get_card_packet (nb);
|
||||
inf->card->driver->recv (inf->card,nb);
|
||||
eth = (struct etherhdr *) nb->data;
|
||||
type = eth->type;
|
||||
grub_netbuff_pull(nb,sizeof (*eth));
|
||||
// grub_printf("ethernet type 58 %x\n",type);
|
||||
// grub_printf("ethernet eth->type 58 %x\n",type);
|
||||
|
||||
if (eth->type <=1500)
|
||||
{
|
||||
llch = (struct llchdr *) nb->data;
|
||||
|
|
10
net/i386/mem.c
Normal file
10
net/i386/mem.c
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
|
||||
void *grub_net_malloc (grub_size_t size)
|
||||
{
|
||||
return grub_malloc (size);
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#include <grub/net/ieee1275/interface.h>
|
||||
#include <grub/net/netbuff.h>
|
||||
#include <grub/ieee1275/ofnet.h>
|
||||
|
||||
static grub_ieee1275_ihandle_t handle;
|
||||
int card_open (void)
|
||||
{
|
||||
|
||||
grub_ieee1275_open (grub_net->dev , &handle);
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int card_close (void)
|
||||
{
|
||||
|
||||
if (handle)
|
||||
grub_ieee1275_close (handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int send_card_buffer (struct grub_net_buff *pack)
|
||||
{
|
||||
|
||||
int actual;
|
||||
grub_ieee1275_write (handle,pack->data,pack->tail - pack->data,&actual);
|
||||
|
||||
return actual;
|
||||
}
|
||||
|
||||
int get_card_packet (struct grub_net_buff *pack __attribute__ ((unused)))
|
||||
{
|
||||
|
||||
int actual, rc;
|
||||
pack->data = pack->tail = pack->head;
|
||||
do
|
||||
{
|
||||
rc = grub_ieee1275_read (handle,pack->data,1500,&actual);
|
||||
|
||||
}while (actual <= 0 || rc < 0);
|
||||
grub_netbuff_put (pack, actual);
|
||||
|
||||
// grub_printf("packsize %d\n",pack->tail - pack->data);
|
||||
return 0;// sizeof (eth) + iph.len;
|
||||
}
|
32
net/ieee1275/mem.c
Normal file
32
net/ieee1275/mem.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include <grub/types.h>
|
||||
#include <grub/err.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/net/mem.h>
|
||||
#define TRASHOLD_SIZE 5 * 1024 * 1024
|
||||
|
||||
void *grub_net_malloc (grub_size_t size)
|
||||
{
|
||||
|
||||
int found = 0;
|
||||
grub_addr_t found_addr;
|
||||
|
||||
if (size <= TRASHOLD_SIZE)
|
||||
return grub_malloc (size);
|
||||
|
||||
for (found_addr = 0x800000; found_addr < + 2000 * 0x100000; found_addr += 0x100000)
|
||||
{
|
||||
if (grub_claimmap (found_addr , size) != -1)
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
grub_error (GRUB_ERR_OUT_OF_MEMORY, "out of memory");
|
||||
|
||||
return found?(void *) found_addr:NULL;
|
||||
|
||||
}
|
|
@ -2,6 +2,8 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/mm.h>
|
||||
|
||||
struct grub_net_network_layer_protocol *grub_net_network_layer_protocols = NULL;
|
||||
|
||||
#define PROTOCOL_REGISTER_FUNCTIONS(layername) \
|
||||
struct grub_net_##layername##_layer_protocol *grub_net_##layername##_layer_protocols;\
|
||||
\
|
||||
|
|
Loading…
Reference in a new issue