aboutsummaryrefslogtreecommitdiff
path: root/board-qemu/virtio-net/module_entry.c
blob: 9e6ceda88edf9a56e4e48a3bee3241177de25e38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/******************************************************************************
 * Copyright (c) 2004, 2011 IBM Corporation
 * All rights reserved.
 * This program and the accompanying materials
 * are made available under the terms of the BSD License
 * which accompanies this distribution, and is available at
 * http://www.opensource.org/licenses/bsd-license.php
 *
 * Contributors:
 *     IBM Corporation - initial implementation
 *****************************************************************************/

#include <string.h>
#include <netdriver_int.h>
#include <libhvcall.h>
#include "virtio-net.h"

extern char __module_start[];
extern char __module_end[];
extern char __bss_start[];
extern char __bss_end[];

snk_kernel_t	*snk_kernel_interface;
snk_module_t	*snk_module_interface;


snk_module_t* module_init(snk_kernel_t *snk_kernel_int, pci_config_t *conf)
{
	long		module_size;

	module_size = __module_end - __module_start;
	if (module_size >= 0x800000) {
		snk_kernel_int->print("Module size (%llu bytes) is too big!\n",
				      module_size);
		return 0;
	}

	memset(__bss_start, 0, __bss_end - __bss_start);

	snk_kernel_interface = snk_kernel_int;
	snk_module_interface = &virtionet_interface;
	snk_module_interface->link_addr = module_init;

	if (snk_kernel_int->version != snk_module_interface->version)
		return 0;

	if (vn_module_init_pci(snk_kernel_int, conf))
		return 0;

	return &virtionet_interface;
}