PERFORCE change 185542 for review
John Baldwin
jhb at FreeBSD.org
Mon Nov 8 21:53:29 UTC 2010
http://p4web.freebsd.org/@@185542?ac=10
Change 185542 by jhb at jhb_jhbbsd on 2010/11/08 21:53:18
IFC @185541
Affected files ...
.. //depot/projects/smpng/share/man/man9/Makefile#20 integrate
.. //depot/projects/smpng/share/man/man9/taskqueue.9#5 integrate
.. //depot/projects/smpng/sys/amd64/acpica/madt.c#23 delete
.. //depot/projects/smpng/sys/boot/common/loader.8#51 integrate
.. //depot/projects/smpng/sys/boot/forth/beastie.4th#12 integrate
.. //depot/projects/smpng/sys/boot/i386/libi386/biosacpi.c#14 integrate
.. //depot/projects/smpng/sys/boot/i386/libi386/i386_module.c#10 integrate
.. //depot/projects/smpng/sys/boot/i386/loader/help.i386#8 integrate
.. //depot/projects/smpng/sys/conf/files.amd64#82 integrate
.. //depot/projects/smpng/sys/conf/files.i386#142 integrate
.. //depot/projects/smpng/sys/contrib/octeon-sdk/cvmx-app-init.h#3 integrate
.. //depot/projects/smpng/sys/contrib/octeon-sdk/cvmx-helper-board.c#4 integrate
.. //depot/projects/smpng/sys/contrib/octeon-sdk/cvmx-helper.c#3 integrate
.. //depot/projects/smpng/sys/dev/mii/brgphy.c#54 integrate
.. //depot/projects/smpng/sys/dev/mii/miidevs#44 integrate
.. //depot/projects/smpng/sys/i386/acpica/madt.c#31 delete
.. //depot/projects/smpng/sys/kern/link_elf.c#54 integrate
.. //depot/projects/smpng/sys/kern/subr_taskqueue.c#49 integrate
.. //depot/projects/smpng/sys/modules/acpi/acpi/Makefile#28 integrate
.. //depot/projects/smpng/sys/sys/taskqueue.h#19 integrate
.. //depot/projects/smpng/sys/x86/acpica/madt.c#1 branch
Differences ...
==== //depot/projects/smpng/share/man/man9/Makefile#20 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD: src/share/man/man9/Makefile,v 1.379 2010/10/24 15:56:21 jh Exp $
+# $FreeBSD: src/share/man/man9/Makefile,v 1.380 2010/11/08 20:56:31 mdf Exp $
MAN= accept_filter.9 \
accf_data.9 \
@@ -1212,6 +1212,7 @@
sysctl_ctx_init.9 sysctl_ctx_entry_find.9 \
sysctl_ctx_init.9 sysctl_ctx_free.9
MLINKS+=taskqueue.9 TASK_INIT.9 \
+ taskqueue.9 taskqueue_cancel.9 \
taskqueue.9 taskqueue_create.9 \
taskqueue.9 taskqueue_create_fast.9 \
taskqueue.9 TASKQUEUE_DECLARE.9 \
==== //depot/projects/smpng/share/man/man9/taskqueue.9#5 (text+ko) ====
@@ -26,7 +26,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/share/man/man9/taskqueue.9,v 1.31 2010/10/13 22:59:04 mdf Exp $
+.\" $FreeBSD: src/share/man/man9/taskqueue.9,v 1.32 2010/11/08 20:56:31 mdf Exp $
.\"
.Dd August 18, 2009
.Dt TASKQUEUE 9
@@ -63,6 +63,8 @@
.Fn taskqueue_enqueue "struct taskqueue *queue" "struct task *task"
.Ft int
.Fn taskqueue_enqueue_fast "struct taskqueue *queue" "struct task *task"
+.Ft int
+.Fn taskqueue_cancel "struct taskqueue *queue" "struct task *task" "u_int *pendp"
.Ft void
.Fn taskqueue_drain "struct taskqueue *queue" "struct task *task"
.Ft int
@@ -162,6 +164,31 @@
.Fn taskqueue_enqueue .
.Pp
The
+.Fn taskqueue_cancel
+function is used to cancel a task.
+The
+.Va ta_pending
+count is cleared, and the old value returned in the reference
+parameter
+.Fa pendp ,
+if it is non- Dv NULL .
+If the task is currently running,
+.Dv EBUSY
+is returned, otherwise 0.
+To implement a blocking
+.Fn taskqueue_cancel
+that waits for a running task to finish, it could look like:
+.Bd -literal -offset indent
+while (taskqueue_cancel(tq, task, NULL) != 0)
+ taskqueue_drain(tq, task);
+.Ed
+.Pp
+Note that, as with
+.Fn taskqueue_drain ,
+the caller is responsible for ensuring that the task is not re-enqueued
+after being canceled.
+.Pp
+The
.Fn taskqueue_drain
function is used to wait for the task to finish.
There is no guarantee that the task will not be
==== //depot/projects/smpng/sys/boot/common/loader.8#51 (text+ko) ====
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/sys/boot/common/loader.8,v 1.98 2010/10/08 12:40:16 uqs Exp $
+.\" $FreeBSD: src/sys/boot/common/loader.8,v 1.99 2010/11/08 21:50:45 jhb Exp $
.\"
.Dd February 15, 2009
.Dt LOADER 8
@@ -334,12 +334,6 @@
while others define behavior just by being set.
Both types of builtin variables are described below.
.Bl -tag -width bootfile
-.It Va acpi_load
-Unset this to disable automatic loading of the ACPI module.
-See also
-.Va hint.acpi.0.disabled
-in
-.Xr device.hints 5 .
.It Va autoboot_delay
Number of seconds
.Ic autoboot
==== //depot/projects/smpng/sys/boot/forth/beastie.4th#12 (text+ko) ====
@@ -23,7 +23,7 @@
\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
\ SUCH DAMAGE.
\
-\ $FreeBSD: src/sys/boot/forth/beastie.4th,v 1.13 2010/09/08 20:10:29 jhb Exp $
+\ $FreeBSD: src/sys/boot/forth/beastie.4th,v 1.14 2010/11/08 21:50:45 jhb Exp $
marker task-beastie.4th
@@ -141,13 +141,11 @@
;
: acpienabled? ( -- flag )
- s" acpi_load" getenv
+ s" hint.acpi.0.rsdp" getenv
dup -1 = if
drop false exit
then
- s" YES" compare-insensitive 0<> if
- false exit
- then
+ 2drop
s" hint.acpi.0.disabled" getenv
dup -1 <> if
s" 0" compare 0<> if
@@ -254,11 +252,9 @@
dup bootkey @ = if 0 boot then
dup bootacpikey @ = if
acpienabled? if
- s" acpi_load" unsetenv
s" 1" s" hint.acpi.0.disabled" setenv
s" 1" s" loader.acpi_disabled_by_user" setenv
else
- s" YES" s" acpi_load" setenv
s" 0" s" hint.acpi.0.disabled" setenv
then
0 boot
@@ -266,7 +262,6 @@
dup bootsafekey @ = if
s" arch-i386" environment? if
drop
- s" acpi_load" unsetenv
s" 1" s" hint.acpi.0.disabled" setenv
s" 1" s" loader.acpi_disabled_by_user" setenv
s" 1" s" hint.apic.0.disabled" setenv
==== //depot/projects/smpng/sys/boot/i386/libi386/biosacpi.c#14 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biosacpi.c,v 1.14 2009/12/10 14:54:29 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biosacpi.c,v 1.15 2010/11/08 21:50:45 jhb Exp $");
#include <stand.h>
#include <machine/stdarg.h>
@@ -40,7 +40,7 @@
#include "actbl.h"
/*
- * Detect ACPI and export information about the APCI BIOS into the
+ * Detect ACPI and export information about the ACPI BIOS into the
* environment.
*/
@@ -56,8 +56,6 @@
char buf[24];
int revision;
- /* XXX check the BIOS datestamp */
-
/* locate and validate the RSDP */
if ((rsdp = biosacpi_find_rsdp()) == NULL)
return;
@@ -82,9 +80,6 @@
sprintf(buf, "%d", rsdp->Length);
setenv("hint.acpi.0.xsdt_length", buf, 1);
}
- /* XXX other tables? */
-
- setenv("acpi_load", "YES", 1);
}
/*
==== //depot/projects/smpng/sys/boot/i386/libi386/i386_module.c#10 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/i386_module.c,v 1.12 2003/08/25 23:28:31 obrien Exp $");
+__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/i386_module.c,v 1.13 2010/11/08 21:50:45 jhb Exp $");
/*
* i386-specific module functionality.
@@ -44,25 +44,7 @@
int
i386_autoload(void)
{
- int error;
- int disabled;
- char *rv;
/* XXX use PnP to locate stuff here */
-
- /* autoload ACPI support */
- /* XXX should be in 4th keyed off acpi_load */
- disabled = 0;
- rv = getenv("hint.acpi.0.disabled");
- if (rv != NULL && strncmp(rv, "0", 1) != 0) {
- disabled = 1;
- }
-
- if (getenv("acpi_load") && (!disabled)) {
- error = mod_load("acpi", NULL, 0, NULL);
- if (error != 0)
- printf("ACPI autoload failed - %s\n", strerror(error));
- }
-
return(0);
}
==== //depot/projects/smpng/sys/boot/i386/loader/help.i386#8 (text+ko) ====
@@ -1,22 +1,4 @@
################################################################################
-# TACPI DControl ACPI module behaviour
-
- $acpi_load
-
- If set, the ACPI module will be loaded. Clear it with
-
- unset acpi_load
-
- $hint.acpi.0.disabled="1"
-
- If set, the ACPI module won't be loaded.
-
- Note that the ACPI autodetection sets a number of hints to
- pass information to the ACPI module. These should not be
- overridden, or system behaviour will be undefined.
-
-
-################################################################################
# Treboot DReboot the system
reboot
==== //depot/projects/smpng/sys/conf/files.amd64#82 (text+ko) ====
@@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
-# $FreeBSD: src/sys/conf/files.amd64,v 1.172 2010/10/28 16:31:39 attilio Exp $
+# $FreeBSD: src/sys/conf/files.amd64,v 1.173 2010/11/08 20:57:02 jhb Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -92,7 +92,6 @@
clean "acpi_wakedata.h"
#
amd64/acpica/acpi_wakeup.c optional acpi
-amd64/acpica/madt.c optional acpi
amd64/amd64/amd64_mem.c optional mem
#amd64/amd64/apic_vector.S standard
amd64/amd64/atomic.c standard
@@ -301,6 +300,7 @@
#
# x86 shared code between IA32, AMD64 and PC98 architectures
#
+x86/acpica/madt.c optional acpi
x86/acpica/srat.c optional acpi
x86/bios/smbios.c optional smbios
x86/bios/vpd.c optional vpd
==== //depot/projects/smpng/sys/conf/files.i386#142 (text+ko) ====
@@ -1,7 +1,7 @@
# This file tells config what files go into building a kernel,
# files marked standard are always included.
#
-# $FreeBSD: src/sys/conf/files.i386,v 1.655 2010/10/28 16:31:39 attilio Exp $
+# $FreeBSD: src/sys/conf/files.i386,v 1.656 2010/11/08 20:57:02 jhb Exp $
#
# The long compile-with and dependency lines are required because of
# limitations in config: backslash-newline doesn't work in strings, and
@@ -247,7 +247,6 @@
no-obj no-implicit-rule before-depend \
clean "acpi_wakecode.h acpi_wakecode.o acpi_wakecode.bin"
#
-i386/acpica/madt.c optional acpi apic
i386/bios/apm.c optional apm
i386/bios/mca_machdep.c optional mca
i386/bios/smapi.c optional smapi
@@ -374,6 +373,7 @@
#
# x86 shared code between IA32, AMD64 and PC98 architectures
#
+x86/acpica/madt.c optional acpi apic
x86/acpica/srat.c optional acpi
x86/bios/smbios.c optional smbios
x86/bios/vpd.c optional vpd
==== //depot/projects/smpng/sys/contrib/octeon-sdk/cvmx-app-init.h#3 (text+ko) ====
@@ -193,6 +193,9 @@
CVMX_BOARD_TYPE_CUST_GCT108 = 10012,
CVMX_BOARD_TYPE_CUST_AGS109 = 10013,
CVMX_BOARD_TYPE_CUST_GCT110 = 10014,
+#if defined(OCTEON_VENDOR_LANNER)
+ CVMX_BOARD_TYPE_CUST_LANNER_MR730= 10021,
+#endif
CVMX_BOARD_TYPE_CUST_DEFINED_MAX = 20000,
/* Set aside a range for customer private use. The SDK won't
@@ -272,6 +275,9 @@
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_GCT108)
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_AGS109)
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_GCT110)
+#if defined(OCTEON_VENDOR_LANNER)
+ ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_LANNER_MR730)
+#endif
ENUM_BRD_TYPE_CASE(CVMX_BOARD_TYPE_CUST_DEFINED_MAX)
/* Customer private range */
==== //depot/projects/smpng/sys/contrib/octeon-sdk/cvmx-helper-board.c#4 (text+ko) ====
@@ -114,9 +114,6 @@
case CVMX_BOARD_TYPE_EBT5800:
case CVMX_BOARD_TYPE_THUNDER:
case CVMX_BOARD_TYPE_NICPRO2:
-#if defined(OCTEON_VENDOR_LANNER)
- case CVMX_BOARD_TYPE_CUST_LANNER_MR955:
-#endif
/* Interface 0 is SPI4, interface 1 is RGMII */
if ((ipd_port >= 16) && (ipd_port < 20))
return ipd_port - 16;
@@ -180,6 +177,15 @@
/* Private vendor-defined boards. */
#if defined(OCTEON_VENDOR_LANNER)
+ case CVMX_BOARD_TYPE_CUST_LANNER_MR955:
+ /* Interface 1 is 12 BCM5482S PHYs. */
+ if ((ipd_port >= 16) && (ipd_port < 28))
+ return ipd_port - 16;
+ return -1;
+ case CVMX_BOARD_TYPE_CUST_LANNER_MR730:
+ if ((ipd_port >= 0) && (ipd_port < 4))
+ return ipd_port;
+ return -1;
case CVMX_BOARD_TYPE_CUST_LANNER_MR320:
/* Port 0 is a Marvell 88E6161 switch, ports 1 and 2 are Marvell
88E1111 interfaces. */
@@ -291,6 +297,10 @@
break;
/* Private vendor-defined boards. */
#if defined(OCTEON_VENDOR_LANNER)
+ case CVMX_BOARD_TYPE_CUST_LANNER_MR730:
+ /* Ports are BCM5482S */
+ is_broadcom_phy = 1;
+ break;
case CVMX_BOARD_TYPE_CUST_LANNER_MR320:
/* Port 0 connects to the switch */
if (ipd_port == 0)
==== //depot/projects/smpng/sys/contrib/octeon-sdk/cvmx-helper.c#3 (text+ko) ====
@@ -105,6 +105,8 @@
#if defined(OCTEON_VENDOR_LANNER)
case CVMX_BOARD_TYPE_CUST_LANNER_MR955:
return 2;
+ case CVMX_BOARD_TYPE_CUST_LANNER_MR730:
+ return 1;
#endif
default:
break;
==== //depot/projects/smpng/sys/dev/mii/brgphy.c#54 (text+ko) ====
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/mii/brgphy.c,v 1.95 2010/10/27 17:16:40 yongari Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/mii/brgphy.c,v 1.96 2010/11/08 21:23:28 jmallett Exp $");
/*
* Driver for the Broadcom BCM54xx/57xx 1000baseTX PHY.
@@ -132,6 +132,7 @@
MII_PHY_DESC(xxBROADCOM, BCM5754),
MII_PHY_DESC(xxBROADCOM, BCM5780),
MII_PHY_DESC(xxBROADCOM, BCM5708C),
+ MII_PHY_DESC(xxBROADCOM_ALT1, BCM5482S),
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5755),
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5787),
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5708S),
==== //depot/projects/smpng/sys/dev/mii/miidevs#44 (text+ko) ====
@@ -1,4 +1,4 @@
-$FreeBSD: src/sys/dev/mii/miidevs,v 1.75 2010/10/27 17:16:40 yongari Exp $
+$FreeBSD: src/sys/dev/mii/miidevs,v 1.76 2010/11/08 21:23:28 jmallett Exp $
/*$NetBSD: miidevs,v 1.6 1999/05/14 11:37:30 drochner Exp $*/
/*-
@@ -145,6 +145,7 @@
model xxBROADCOM BCM5714 0x0034 BCM5714 10/100/1000baseTX PHY
model xxBROADCOM BCM5780 0x0035 BCM5780 10/100/1000baseTX PHY
model xxBROADCOM BCM5708C 0x0036 BCM5708C 10/100/1000baseTX PHY
+model xxBROADCOM_ALT1 BCM5482S 0x000b BCM5482S Dual-Port 10/100/1000baseX/FX PHY
model xxBROADCOM_ALT1 BCM5755 0x000c BCM5755 10/100/1000baseTX PHY
model xxBROADCOM_ALT1 BCM5787 0x000e BCM5787 10/100/1000baseTX PHY
model xxBROADCOM_ALT1 BCM5708S 0x0015 BCM5708S 1000/2500BaseSX PHY
==== //depot/projects/smpng/sys/kern/link_elf.c#54 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/link_elf.c,v 1.107 2010/10/02 16:04:50 kib Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/link_elf.c,v 1.108 2010/11/08 20:57:08 mdf Exp $");
#include "opt_ddb.h"
#include "opt_gdb.h"
@@ -74,52 +74,52 @@
#define MAXSEGS 4
typedef struct elf_file {
- struct linker_file lf; /* Common fields */
- int preloaded; /* Was file pre-loaded */
- caddr_t address; /* Relocation address */
+ struct linker_file lf; /* Common fields */
+ int preloaded; /* Was file pre-loaded */
+ caddr_t address; /* Relocation address */
#ifdef SPARSE_MAPPING
- vm_object_t object; /* VM object to hold file pages */
+ vm_object_t object; /* VM object to hold file pages */
#endif
- Elf_Dyn* dynamic; /* Symbol table etc. */
- Elf_Hashelt nbuckets; /* DT_HASH info */
- Elf_Hashelt nchains;
- const Elf_Hashelt* buckets;
- const Elf_Hashelt* chains;
- caddr_t hash;
- caddr_t strtab; /* DT_STRTAB */
- int strsz; /* DT_STRSZ */
- const Elf_Sym* symtab; /* DT_SYMTAB */
- Elf_Addr* got; /* DT_PLTGOT */
- const Elf_Rel* pltrel; /* DT_JMPREL */
- int pltrelsize; /* DT_PLTRELSZ */
- const Elf_Rela* pltrela; /* DT_JMPREL */
- int pltrelasize; /* DT_PLTRELSZ */
- const Elf_Rel* rel; /* DT_REL */
- int relsize; /* DT_RELSZ */
- const Elf_Rela* rela; /* DT_RELA */
- int relasize; /* DT_RELASZ */
- caddr_t modptr;
- const Elf_Sym* ddbsymtab; /* The symbol table we are using */
- long ddbsymcnt; /* Number of symbols */
- caddr_t ddbstrtab; /* String table */
- long ddbstrcnt; /* number of bytes in string table */
- caddr_t symbase; /* malloc'ed symbold base */
- caddr_t strbase; /* malloc'ed string base */
- caddr_t ctftab; /* CTF table */
- long ctfcnt; /* number of bytes in CTF table */
- caddr_t ctfoff; /* CTF offset table */
- caddr_t typoff; /* Type offset table */
- long typlen; /* Number of type entries. */
- Elf_Addr pcpu_start; /* Pre-relocation pcpu set start. */
- Elf_Addr pcpu_stop; /* Pre-relocation pcpu set stop. */
- Elf_Addr pcpu_base; /* Relocated pcpu set address. */
+ Elf_Dyn *dynamic; /* Symbol table etc. */
+ Elf_Hashelt nbuckets; /* DT_HASH info */
+ Elf_Hashelt nchains;
+ const Elf_Hashelt *buckets;
+ const Elf_Hashelt *chains;
+ caddr_t hash;
+ caddr_t strtab; /* DT_STRTAB */
+ int strsz; /* DT_STRSZ */
+ const Elf_Sym *symtab; /* DT_SYMTAB */
+ Elf_Addr *got; /* DT_PLTGOT */
+ const Elf_Rel *pltrel; /* DT_JMPREL */
+ int pltrelsize; /* DT_PLTRELSZ */
+ const Elf_Rela *pltrela; /* DT_JMPREL */
+ int pltrelasize; /* DT_PLTRELSZ */
+ const Elf_Rel *rel; /* DT_REL */
+ int relsize; /* DT_RELSZ */
+ const Elf_Rela *rela; /* DT_RELA */
+ int relasize; /* DT_RELASZ */
+ caddr_t modptr;
+ const Elf_Sym *ddbsymtab; /* The symbol table we are using */
+ long ddbsymcnt; /* Number of symbols */
+ caddr_t ddbstrtab; /* String table */
+ long ddbstrcnt; /* number of bytes in string table */
+ caddr_t symbase; /* malloc'ed symbold base */
+ caddr_t strbase; /* malloc'ed string base */
+ caddr_t ctftab; /* CTF table */
+ long ctfcnt; /* number of bytes in CTF table */
+ caddr_t ctfoff; /* CTF offset table */
+ caddr_t typoff; /* Type offset table */
+ long typlen; /* Number of type entries. */
+ Elf_Addr pcpu_start; /* Pre-relocation pcpu set start. */
+ Elf_Addr pcpu_stop; /* Pre-relocation pcpu set stop. */
+ Elf_Addr pcpu_base; /* Relocated pcpu set address. */
#ifdef VIMAGE
- Elf_Addr vnet_start; /* Pre-relocation vnet set start. */
- Elf_Addr vnet_stop; /* Pre-relocation vnet set stop. */
- Elf_Addr vnet_base; /* Relocated vnet set address. */
+ Elf_Addr vnet_start; /* Pre-relocation vnet set start. */
+ Elf_Addr vnet_stop; /* Pre-relocation vnet set stop. */
+ Elf_Addr vnet_base; /* Relocated vnet set address. */
#endif
#ifdef GDB
- struct link_map gdb; /* hooks for gdb */
+ struct link_map gdb; /* hooks for gdb */
#endif
} *elf_file_t;
@@ -127,70 +127,71 @@
static int link_elf_link_common_finish(linker_file_t);
static int link_elf_link_preload(linker_class_t cls,
- const char*, linker_file_t*);
+ const char *, linker_file_t *);
static int link_elf_link_preload_finish(linker_file_t);
-static int link_elf_load_file(linker_class_t, const char*, linker_file_t*);
-static int link_elf_lookup_symbol(linker_file_t, const char*,
- c_linker_sym_t*);
-static int link_elf_symbol_values(linker_file_t, c_linker_sym_t, linker_symval_t*);
-static int link_elf_search_symbol(linker_file_t, caddr_t value,
- c_linker_sym_t* sym, long* diffp);
+static int link_elf_load_file(linker_class_t, const char *,
+ linker_file_t *);
+static int link_elf_lookup_symbol(linker_file_t, const char *,
+ c_linker_sym_t *);
+static int link_elf_symbol_values(linker_file_t, c_linker_sym_t,
+ linker_symval_t *);
+static int link_elf_search_symbol(linker_file_t, caddr_t,
+ c_linker_sym_t *, long *);
static void link_elf_unload_file(linker_file_t);
static void link_elf_unload_preload(linker_file_t);
static int link_elf_lookup_set(linker_file_t, const char *,
- void ***, void ***, int *);
+ void ***, void ***, int *);
static int link_elf_each_function_name(linker_file_t,
- int (*)(const char *, void *),
- void *);
+ int (*)(const char *, void *), void *);
static int link_elf_each_function_nameval(linker_file_t,
- linker_function_nameval_callback_t,
- void *);
+ linker_function_nameval_callback_t, void *);
static void link_elf_reloc_local(linker_file_t);
static long link_elf_symtab_get(linker_file_t, const Elf_Sym **);
static long link_elf_strtab_get(linker_file_t, caddr_t *);
-static Elf_Addr elf_lookup(linker_file_t lf, Elf_Size symidx, int deps);
+static Elf_Addr elf_lookup(linker_file_t, Elf_Size, int);
static kobj_method_t link_elf_methods[] = {
- KOBJMETHOD(linker_lookup_symbol, link_elf_lookup_symbol),
- KOBJMETHOD(linker_symbol_values, link_elf_symbol_values),
- KOBJMETHOD(linker_search_symbol, link_elf_search_symbol),
- KOBJMETHOD(linker_unload, link_elf_unload_file),
- KOBJMETHOD(linker_load_file, link_elf_load_file),
- KOBJMETHOD(linker_link_preload, link_elf_link_preload),
- KOBJMETHOD(linker_link_preload_finish, link_elf_link_preload_finish),
- KOBJMETHOD(linker_lookup_set, link_elf_lookup_set),
- KOBJMETHOD(linker_each_function_name, link_elf_each_function_name),
- KOBJMETHOD(linker_each_function_nameval, link_elf_each_function_nameval),
- KOBJMETHOD(linker_ctf_get, link_elf_ctf_get),
- KOBJMETHOD(linker_symtab_get, link_elf_symtab_get),
- KOBJMETHOD(linker_strtab_get, link_elf_strtab_get),
- { 0, 0 }
+ KOBJMETHOD(linker_lookup_symbol, link_elf_lookup_symbol),
+ KOBJMETHOD(linker_symbol_values, link_elf_symbol_values),
+ KOBJMETHOD(linker_search_symbol, link_elf_search_symbol),
+ KOBJMETHOD(linker_unload, link_elf_unload_file),
+ KOBJMETHOD(linker_load_file, link_elf_load_file),
+ KOBJMETHOD(linker_link_preload, link_elf_link_preload),
+ KOBJMETHOD(linker_link_preload_finish, link_elf_link_preload_finish),
+ KOBJMETHOD(linker_lookup_set, link_elf_lookup_set),
+ KOBJMETHOD(linker_each_function_name, link_elf_each_function_name),
+ KOBJMETHOD(linker_each_function_nameval, link_elf_each_function_nameval),
+ KOBJMETHOD(linker_ctf_get, link_elf_ctf_get),
+ KOBJMETHOD(linker_symtab_get, link_elf_symtab_get),
+ KOBJMETHOD(linker_strtab_get, link_elf_strtab_get),
+ { 0, 0 }
};
static struct linker_class link_elf_class = {
#if ELF_TARG_CLASS == ELFCLASS32
- "elf32",
+ "elf32",
#else
- "elf64",
+ "elf64",
#endif
- link_elf_methods, sizeof(struct elf_file)
+ link_elf_methods, sizeof(struct elf_file)
};
-static int parse_dynamic(elf_file_t ef);
-static int relocate_file(elf_file_t ef);
-static int link_elf_preload_parse_symbols(elf_file_t ef);
+static int parse_dynamic(elf_file_t);
+static int relocate_file(elf_file_t);
+static int link_elf_preload_parse_symbols(elf_file_t);
#ifdef GDB
-static void r_debug_state(struct r_debug *dummy_one,
- struct link_map *dummy_two);
+static void r_debug_state(struct r_debug *, struct link_map *);
/*
* A list of loaded modules for GDB to use for loading symbols.
*/
struct r_debug r_debug;
-#define GDB_STATE(s) r_debug.r_state = s; r_debug_state(NULL, NULL);
+#define GDB_STATE(s) do { \
+ r_debug.r_state = s; r_debug_state(NULL, NULL); \
+} while (0)
/*
* Function for the debugger to set a breakpoint on to gain control.
@@ -204,35 +205,37 @@
static void
link_elf_add_gdb(struct link_map *l)
{
- struct link_map *prev;
+ struct link_map *prev;
- l->l_next = NULL;
+ l->l_next = NULL;
- if (r_debug.r_map == NULL) {
- /* Add first. */
- l->l_prev = NULL;
- r_debug.r_map = l;
- } else {
- /* Append to list. */
- for (prev = r_debug.r_map; prev->l_next != NULL; prev = prev->l_next)
- ;
- l->l_prev = prev;
- prev->l_next = l;
- }
+ if (r_debug.r_map == NULL) {
+ /* Add first. */
+ l->l_prev = NULL;
+ r_debug.r_map = l;
+ } else {
+ /* Append to list. */
+ for (prev = r_debug.r_map;
+ prev->l_next != NULL;
+ prev = prev->l_next)
+ ;
+ l->l_prev = prev;
+ prev->l_next = l;
+ }
}
static void
link_elf_delete_gdb(struct link_map *l)
{
- if (l->l_prev == NULL) {
- /* Remove first. */
- if ((r_debug.r_map = l->l_next) != NULL)
- l->l_next->l_prev = NULL;
- } else {
- /* Remove any but first. */
- if ((l->l_prev->l_next = l->l_next) != NULL)
- l->l_next->l_prev = l->l_prev;
- }
+ if (l->l_prev == NULL) {
+ /* Remove first. */
+ if ((r_debug.r_map = l->l_next) != NULL)
+ l->l_next->l_prev = NULL;
+ } else {
+ /* Remove any but first. */
+ if ((l->l_prev->l_next = l->l_next) != NULL)
+ l->l_next->l_prev = l->l_prev;
+ }
}
#endif /* GDB */
@@ -262,85 +265,86 @@
link_elf_link_common_finish(linker_file_t lf)
{
#ifdef GDB
- elf_file_t ef = (elf_file_t)lf;
- char *newfilename;
+ elf_file_t ef = (elf_file_t)lf;
+ char *newfilename;
#endif
- int error;
+ int error;
- /* Notify MD code that a module is being loaded. */
- error = elf_cpu_load_file(lf);
- if (error)
- return (error);
+ /* Notify MD code that a module is being loaded. */
+ error = elf_cpu_load_file(lf);
+ if (error != 0)
+ return (error);
#ifdef GDB
- GDB_STATE(RT_ADD);
- ef->gdb.l_addr = lf->address;
- newfilename = malloc(strlen(lf->filename) + 1, M_LINKER, M_WAITOK);
- strcpy(newfilename, lf->filename);
- ef->gdb.l_name = newfilename;
- ef->gdb.l_ld = ef->dynamic;
- link_elf_add_gdb(&ef->gdb);
- GDB_STATE(RT_CONSISTENT);
+ GDB_STATE(RT_ADD);
+ ef->gdb.l_addr = lf->address;
+ newfilename = malloc(strlen(lf->filename) + 1, M_LINKER, M_WAITOK);
+ strcpy(newfilename, lf->filename);
+ ef->gdb.l_name = newfilename;
+ ef->gdb.l_ld = ef->dynamic;
+ link_elf_add_gdb(&ef->gdb);
+ GDB_STATE(RT_CONSISTENT);
#endif
- return (0);
+ return (0);
}
static void
link_elf_init(void* arg)
{
- Elf_Dyn *dp;
- caddr_t modptr, baseptr, sizeptr;
- elf_file_t ef;
- char *modname;
+ Elf_Dyn *dp;
+ caddr_t modptr, baseptr, sizeptr;
+ elf_file_t ef;
+ char *modname;
- linker_add_class(&link_elf_class);
+ linker_add_class(&link_elf_class);
- dp = (Elf_Dyn*) &_DYNAMIC;
- modname = NULL;
- modptr = preload_search_by_type("elf" __XSTRING(__ELF_WORD_SIZE) " kernel");
- if (modptr == NULL)
- modptr = preload_search_by_type("elf kernel");
- if (modptr)
- modname = (char *)preload_search_info(modptr, MODINFO_NAME);
- if (modname == NULL)
- modname = "kernel";
- linker_kernel_file = linker_make_file(modname, &link_elf_class);
- if (linker_kernel_file == NULL)
- panic("link_elf_init: Can't create linker structures for kernel");
+ dp = (Elf_Dyn *)&_DYNAMIC;
+ modname = NULL;
+ modptr = preload_search_by_type("elf" __XSTRING(__ELF_WORD_SIZE) " kernel");
+ if (modptr == NULL)
+ modptr = preload_search_by_type("elf kernel");
+ if (modptr != NULL)
+ modname = (char *)preload_search_info(modptr, MODINFO_NAME);
+ if (modname == NULL)
+ modname = "kernel";
+ linker_kernel_file = linker_make_file(modname, &link_elf_class);
+ if (linker_kernel_file == NULL)
+ panic("%s: Can't create linker structures for kernel",
+ __func__);
- ef = (elf_file_t) linker_kernel_file;
- ef->preloaded = 1;
- ef->address = 0;
+ ef = (elf_file_t) linker_kernel_file;
+ ef->preloaded = 1;
+ ef->address = 0;
#ifdef SPARSE_MAPPING
- ef->object = 0;
+ ef->object = 0;
#endif
- ef->dynamic = dp;
+ ef->dynamic = dp;
- if (dp)
- parse_dynamic(ef);
- linker_kernel_file->address = (caddr_t) KERNBASE;
- linker_kernel_file->size = -(intptr_t)linker_kernel_file->address;
+ if (dp != NULL)
+ parse_dynamic(ef);
+ linker_kernel_file->address = (caddr_t) KERNBASE;
+ linker_kernel_file->size = -(intptr_t)linker_kernel_file->address;
- if (modptr) {
- ef->modptr = modptr;
- baseptr = preload_search_info(modptr, MODINFO_ADDR);
- if (baseptr)
- linker_kernel_file->address = *(caddr_t *)baseptr;
- sizeptr = preload_search_info(modptr, MODINFO_SIZE);
- if (sizeptr)
- linker_kernel_file->size = *(size_t *)sizeptr;
- }
- (void)link_elf_preload_parse_symbols(ef);
+ if (modptr != NULL) {
+ ef->modptr = modptr;
+ baseptr = preload_search_info(modptr, MODINFO_ADDR);
+ if (baseptr != NULL)
+ linker_kernel_file->address = *(caddr_t *)baseptr;
+ sizeptr = preload_search_info(modptr, MODINFO_SIZE);
+ if (sizeptr != NULL)
+ linker_kernel_file->size = *(size_t *)sizeptr;
+ }
+ (void)link_elf_preload_parse_symbols(ef);
#ifdef GDB
- r_debug.r_map = NULL;
- r_debug.r_brk = r_debug_state;
- r_debug.r_state = RT_CONSISTENT;
+ r_debug.r_map = NULL;
+ r_debug.r_brk = r_debug_state;
+ r_debug.r_state = RT_CONSISTENT;
#endif
- (void)link_elf_link_common_finish(linker_kernel_file);
- linker_kernel_file->flags |= LINKER_FILE_LINKED;
+ (void)link_elf_link_common_finish(linker_kernel_file);
+ linker_kernel_file->flags |= LINKER_FILE_LINKED;
}
SYSINIT(link_elf, SI_SUB_KLD, SI_ORDER_THIRD, link_elf_init, 0);
@@ -348,795 +352,807 @@
static int
link_elf_preload_parse_symbols(elf_file_t ef)
{
- caddr_t pointer;
- caddr_t ssym, esym, base;
- caddr_t strtab;
- int strcnt;
- Elf_Sym* symtab;
- int symcnt;
+ caddr_t pointer;
+ caddr_t ssym, esym, base;
+ caddr_t strtab;
+ int strcnt;
+ Elf_Sym *symtab;
+ int symcnt;
- if (ef->modptr == NULL)
- return 0;
- pointer = preload_search_info(ef->modptr, MODINFO_METADATA|MODINFOMD_SSYM);
- if (pointer == NULL)
- return 0;
- ssym = *(caddr_t *)pointer;
- pointer = preload_search_info(ef->modptr, MODINFO_METADATA|MODINFOMD_ESYM);
- if (pointer == NULL)
- return 0;
- esym = *(caddr_t *)pointer;
+ if (ef->modptr == NULL)
+ return (0);
+ pointer = preload_search_info(ef->modptr,
+ MODINFO_METADATA | MODINFOMD_SSYM);
+ if (pointer == NULL)
+ return (0);
+ ssym = *(caddr_t *)pointer;
+ pointer = preload_search_info(ef->modptr,
+ MODINFO_METADATA | MODINFOMD_ESYM);
+ if (pointer == NULL)
+ return (0);
+ esym = *(caddr_t *)pointer;
- base = ssym;
+ base = ssym;
- symcnt = *(long *)base;
- base += sizeof(long);
- symtab = (Elf_Sym *)base;
- base += roundup(symcnt, sizeof(long));
+ symcnt = *(long *)base;
+ base += sizeof(long);
+ symtab = (Elf_Sym *)base;
+ base += roundup(symcnt, sizeof(long));
- if (base > esym || base < ssym) {
- printf("Symbols are corrupt!\n");
- return EINVAL;
- }
+ if (base > esym || base < ssym) {
+ printf("Symbols are corrupt!\n");
+ return (EINVAL);
+ }
- strcnt = *(long *)base;
- base += sizeof(long);
- strtab = base;
- base += roundup(strcnt, sizeof(long));
+ strcnt = *(long *)base;
+ base += sizeof(long);
+ strtab = base;
+ base += roundup(strcnt, sizeof(long));
- if (base > esym || base < ssym) {
- printf("Symbols are corrupt!\n");
- return EINVAL;
- }
+ if (base > esym || base < ssym) {
+ printf("Symbols are corrupt!\n");
+ return (EINVAL);
+ }
- ef->ddbsymtab = symtab;
- ef->ddbsymcnt = symcnt / sizeof(Elf_Sym);
- ef->ddbstrtab = strtab;
- ef->ddbstrcnt = strcnt;
+ ef->ddbsymtab = symtab;
+ ef->ddbsymcnt = symcnt / sizeof(Elf_Sym);
+ ef->ddbstrtab = strtab;
+ ef->ddbstrcnt = strcnt;
- return 0;
+ return (0);
}
static int
parse_dynamic(elf_file_t ef)
{
- Elf_Dyn *dp;
- int plttype = DT_REL;
+ Elf_Dyn *dp;
+ int plttype = DT_REL;
- for (dp = ef->dynamic; dp->d_tag != DT_NULL; dp++) {
- switch (dp->d_tag) {
- case DT_HASH:
- {
- /* From src/libexec/rtld-elf/rtld.c */
- const Elf_Hashelt *hashtab = (const Elf_Hashelt *)
- (ef->address + dp->d_un.d_ptr);
- ef->nbuckets = hashtab[0];
- ef->nchains = hashtab[1];
- ef->buckets = hashtab + 2;
- ef->chains = ef->buckets + ef->nbuckets;
- break;
- }
- case DT_STRTAB:
- ef->strtab = (caddr_t) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_STRSZ:
- ef->strsz = dp->d_un.d_val;
- break;
- case DT_SYMTAB:
- ef->symtab = (Elf_Sym*) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_SYMENT:
- if (dp->d_un.d_val != sizeof(Elf_Sym))
- return ENOEXEC;
- break;
- case DT_PLTGOT:
- ef->got = (Elf_Addr *) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_REL:
- ef->rel = (const Elf_Rel *) (ef->address + dp->d_un.d_ptr);
- break;
- case DT_RELSZ:
- ef->relsize = dp->d_un.d_val;
- break;
- case DT_RELENT:
- if (dp->d_un.d_val != sizeof(Elf_Rel))
- return ENOEXEC;
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list