From 0855a2af7daae64d7783e2905bc6ca9a85f44a64 Mon Sep 17 00:00:00 2001 From: Jordan Gordeev Date: Sat, 27 Dec 2008 17:50:04 +0100 Subject: [PATCH] Bring in the remainder of the post-SoC amd64 enchilada. Minor-tweaks: corecode@ Via: corecode@ --- etc/etc.amd64/disktab | 238 +++++++++++++++++++ etc/etc.amd64/ttys | 308 +++++++++++++++++++++++++ sys/bus/pci/pci.c | 2 +- sys/conf/files | 2 - sys/config/AMD64_GENERIC | 10 +- sys/cpu/amd64/include/atomic.h | 3 +- sys/cpu/amd64/misc/amd64-gdbstub.c | 2 +- sys/dev/misc/syscons/syscons.c | 12 + sys/dev/video/fb/fbreg.h | 2 +- sys/dev/video/fb/vga.c | 18 +- sys/kern/init_main.c | 4 + sys/kern/kern_ktr.c | 69 +++++- sys/kern/lwkt_thread.c | 22 ++ sys/platform/pc32/conf/files | 3 + sys/platform/pc64/amd64/genassym.c | 9 + sys/platform/pc64/amd64/machdep.c | 118 +++++----- sys/platform/pc64/amd64/nexus.c | 1 + sys/platform/pc64/amd64/support.s | 14 +- sys/platform/pc64/amd64/swtch.s | 87 +++---- sys/platform/pc64/amd64/trap.c | 41 +++- sys/platform/pc64/amd64/vm_machdep.c | 46 +++- sys/platform/pc64/apic/apic_vector.s | 2 +- sys/platform/pc64/include/globaldata.h | 3 +- sys/platform/pc64/isa/asc.c | 4 +- sys/platform/pc64/isa/clock.c | 2 +- sys/platform/pc64/isa/intr_machdep.c | 2 +- sys/platform/pc64/isa/npx.c | 2 +- sys/platform/pc64/isa/prof_machdep.c | 2 +- sys/sys/ktr.h | 9 +- sys/sys/proc.h | 2 +- 30 files changed, 889 insertions(+), 150 deletions(-) create mode 100644 etc/etc.amd64/disktab create mode 100644 etc/etc.amd64/ttys diff --git a/etc/etc.amd64/disktab b/etc/etc.amd64/disktab new file mode 100644 index 0000000000..6fc7545dfd --- /dev/null +++ b/etc/etc.amd64/disktab @@ -0,0 +1,238 @@ +# $FreeBSD: src/etc/etc.i386/disktab,v 1.20.2.2 2002/04/15 00:44:15 dougb Exp $ +# $DragonFly: src/etc/etc.i386/disktab,v 1.3 2007/05/18 17:14:12 dillon Exp $ +# +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, ns*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) +# +# Obsolete keys no longer supported: +# b0 used to allow specification of boot0 +# b1 used to allow specification of boot1 +# d[0-4] used to be drive-type-dependent parameters +# +# Software driven bad sector tables are no longer supported (if +# they ever were in the first place). + +# Floppy formats: +# +# To make a filesystem on a floppy: +# fdformat [-f ] fd[.] +# disklabel -B -r -w fd[.] fd +# newfs fd[.] +# +# with : +# -t 2 - two heads +# -u 9|15|18 - sectors per track +# (using the default value of 1/4096 is not much useful for floppies) +# -l 1 - interleave 1 (for most floppies) +# -i 65536 - bytes of data per i-node +# (the default -i value will render you with a floppy wasting way +# too much space in i-node areas) +# + +fd360:\ + :ty=floppy:se#512:nt#2:rm#300:ns#9:nc#40:\ + :pa#720:oa#0:ba#4096:fa#512:\ + :pb#720:ob#0:bb#4096:fb#512:\ + :pc#720:oc#0:bc#4096:fc#512: + +fd720:\ + :ty=floppy:se#512:nt#2:rm#300:ns#9:nc#80:\ + :pa#1440:oa#0:ba#4096:fa#512:\ + :pb#1440:ob#0:bb#4096:fb#512:\ + :pc#1440:oc#0:bc#4096:fc#512: + +fd1200|floppy5|5in|5.25in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#360:ns#15:nc#80:\ + :pa#2400:oa#0:ba#4096:fa#512:\ + :pb#2400:ob#0:bb#4096:fb#512:\ + :pc#2400:oc#0:bc#4096:fc#512: + +fd1440|floppy|floppy3|3in|3.5in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#80:\ + :pa#2880:oa#0:ba#4096:fa#512:\ + :pb#2880:ob#0:bb#4096:fb#512:\ + :pc#2880:oc#0:bc#4096:fc#512: + +# +# Stressed floppy-formats. No guarantees given. +# + +fd800:\ + :ty=floppy:se#512:nt#2:rm#300:ns#10:nc#80:\ + :pa#1600:oa#0:ba#4096:fa#512:\ + :pb#1600:ob#0:bb#4096:fb#512:\ + :pc#1600:oc#0:bc#4096:fc#512: + +fd820:\ + :ty=floppy:se#512:nt#2:rm#300:ns#10:nc#82:\ + :pa#1640:oa#0:ba#4096:fa#512:\ + :pb#1640:ob#0:bb#4096:fb#512:\ + :pc#1640:oc#0:bc#4096:fc#512: + +fd1480:\ + :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#82:\ + :pa#2952:oa#0:ba#4096:fa#512:\ + :pb#2952:ob#0:bb#4096:fb#512:\ + :pc#2952:oc#0:bc#4096:fc#512: + +fd1720:\ + :ty=floppy:se#512:nt#2:rm#300:ns#21:nc#82:\ + :pa#3444:oa#0:ba#4096:fa#512:\ + :pb#3444:ob#0:bb#4096:fb#512:\ + :pc#3444:oc#0:bc#4096:fc#512: + +# +# LS-120 floppy-format. +# +fd120m|floppy120|floppy120m|3.5in LS-120 Floppy:\ + :ty=floppy:se#512:nt#8:rm#300:ns#32:nc#963:\ + :pa#246528:oa#0:ba#4096:fa#512:\ + :pb#246528:ob#0:bb#4096:fb#512:\ + :pc#246528:oc#0:bc#4096:fc#512: + +# +# Harddisk formats +# +qp120at|Quantum Peripherals 120MB IDE:\ + :dt=ESDI:ty=winchester:se#512:nt#9:ns#32:nc#813:sf: \ + :pa#13824:oa#0:ta=4.2BSD:ba#4096:fa#512: \ + :pb#13824:ob#13824:tb=swap: \ + :pc#234144:oc#0: \ + :ph#206496:oh#27648:th=4.2BSD:bh#4096:fh#512: + +pan60|Panasonic Laptop's 60MB IDE:\ + :dt=ST506:ty=winchester:se#512:nt#13:ns#17:nc#565:\ + :pa#13260:oa#0:ta=4.2BSD:ba#4096:fa#512:\ + :pb#13260:ob#13260:tb=swap: \ + :pc#124865:oc#0: \ + :ph#97682:oh#26520:th=4.2BSD:bh#4096:fh#512: + +mk156|toshiba156|Toshiba MK156 156Mb:\ + :dt=SCSI:ty=winchester:se#512:nt#10:ns#35:nc#825:\ + :pa#15748:oa#0:ba#4096:fa#512:ta=4.2BSD:\ + :pb#15748:ob#15748:tb=swap:\ + :pc#288750:oc#0:\ + :ph#257250:oh#31500:bh#4096:fh#512:th=4.2BSD: + +cp3100|Connor Peripherals 100MB IDE:\ + :dt=ST506:ty=winchester:se#512:nt#8:ns#33:nc#766: \ + :pa#12144:oa#0:ta=4.2BSD:ba#4096:fa#512: \ + :pb#12144:ob#12144:tb=swap: \ + :pc#202224:oc#0: \ + :ph#177936:oh#24288:th=4.2BSD:bh#4096:fh#512: + +# a == root +# b == swap +# c == d == whole disk +# e == /var +# f == scratch +# h == /usr + +cp3100new|Connor Peripherals 100MB IDE, with a different configuration:\ + :dt=ST506:ty=winchester:se#512:nt#8:ns#33:nc#766: \ + :pa#15840:oa#0:ta=4.2BSD:ba#4096:fa#512: \ + :pb#24288:ob#15840:tb=swap: \ + :pc#202224:oc#0: \ + :pd#202224:od#0: \ + :pe#15840:oe#40128:te=4.2BSD:be#4096:fe#512: \ + :pg#15840:og#55968:tg=4.2BSD:bg#4096:fg#512: \ + :ph#130416:oh#71808:th=4.2BSD:bh#4096:fh#512: + +maxtor4380|Maxtor XT4380E ESDI :\ + :dt=ESDI:ty=winchester:se#512:nt#15:ns#36:nc#1222:sf: \ + :pa#21600:oa#0:ta=4.2BSD:ba#4096:fa#512:\ + :pb#21600:ob#21600:tb=swap: \ + :pc#659880:oc#0: \ + :pd#216000:od#53200:td=4.2BSD:bd#4096:fd#512: \ + :ph#398520:oh#269200:th=4.2BSD:bh#4096:fh#512: + +miniscribe9380|compaq38|Miniscribe 9380 ESDI :\ + :ty=winchester:dt=ESDI:se#512:nt#15:ns#35:nc#1223:rm#3600:sf: \ + :pa#21000:oa#0:ba#8192:fa#1024:ta=4.2BSD: \ + :pb#42000:ob#21000:tb=swap: \ + :pc#642075:oc#0: \ + :pd#21000:od#63000:bd#8192:fd#1024:td=4.2BSD: \ + :ph#556500:oh#84000:bh#8192:fh#1024:th=4.2BSD: + +ida4|compaq88|Compaq IDA (4 drives) :\ + :ty=winchester:dt=IDA:se#512:nt#16:ns#63:nc#1644:rm#3600:\ + :pa#20160:oa#0:ba#8192:fa#1024:ta=4.2BSD: \ + :pb#80640:ob#20160:tb=swap: \ + :pc#1659168:oc#0: \ + :pd#201600:od#100800:bd#8192:fd#1024:td=4.2BSD: \ + :pe#20160:oe#1310400:be#8192:fe#1024:te=4.2BSD: \ + :ph#1008000:oh#302400:bh#8192:fh#1024:th=4.2BSD: \ + :pg#302400:og#1330560:bg#4096:fg#512:tg=4.2BSD: + +fuji513|Fujitsu M22XXXX: \ + :ty=winchester:dt=ESDI:se#512:nt#16:ns#63:nc#954:rm#3600:\ + :pa#20160:oa#82656:ba#4096:fa#512:ta=4.2BSD: \ + :pb#40320:ob#102816:tb=swap: \ + :pc#961632:oc#0: \ + :ph#656208:oh#143136:bh#4096:fh#512:th=4.2BSD: + +sony650|Sony 650 MB MOD|\ + :ty=removable:dt=SCSI:se#512:nt#1:ns#31:nc#18600:ts#1:rm#4800:\ + :pc#576600:oc#0:\ + :pa#576600:oa#0:ta=4.2BSD:ba#8192:fa#1024: + +mta3230|mo230|IBM MTA-3230 230 Meg 3.5inch Magneto-Optical:\ + :ty=removeable:dt=SCSI:rm#3600:\ + :se#512:nt#64:ns#32:nc#216:sc#2048:su#444384:\ + :pa#444384:oa#0:ba#4096:fa#0:ta=4.2BSD:\ + :pc#444384:oc#0: + +minimum:ty=mfs:se#512:nt#1:rm#300:\ + :ns#2880:nc#1:\ + :pa#2880:oa#0:ba#4096:fa#512:\ + :pc#2880:oc#0:bc#4096:fc#512: + +minimum2:ty=mfs:se#512:nt#1:rm#300:\ + :ns#5760:nc#1:\ + :pa#5760:oa#0:ba#4096:fa#512:\ + :pc#5760:oc#0:bc#4096:fc#512: + +minimum3:ty=mfs:se#512:nt#1:rm#300:\ + :ns#8640:nc#1:\ + :pa#8640:oa#0:ba#4096:fa#512:\ + :pc#8640:oc#0:bc#4096:fc#512: + +zip100|zip 100:\ + :ty=removable:se#512:nc#96:nt#64:ns#32:\ + :pa#196608:oa#0:ba#4096:fa#512:\ + :pb#196608:ob#0:bb#4096:fb#512:\ + :pc#196608:oc#0:bc#4096:fc#512: + +zip250|zip 250:\ + :ty=removable:se#512:nc#239:nt#64:ns#32:\ + :pa#489472:oa#0:ba#4096:fa#512:\ + :pb#489472:ob#0:bb#4096:fb#512:\ + :pc#489472:oc#0:bc#4096:fc#512: + +orb2200|orb22|orb:\ + :ty=removable:ns#63:nt#128:nc#4273:sc#1008:su#4307184:se#512:\ + :pa#4307184:oa#0:ba#8192:fa#1024:\ + :pc#4307184:oc#0:bc#8192:fc#1024: + diff --git a/etc/etc.amd64/ttys b/etc/etc.amd64/ttys new file mode 100644 index 0000000000..e15be96df9 --- /dev/null +++ b/etc/etc.amd64/ttys @@ -0,0 +1,308 @@ +# +# $FreeBSD: src/etc/etc.i386/ttys,v 1.8 2000/01/29 12:18:03 obrien Exp $ +# $DragonFly: src/etc/etc.i386/ttys,v 1.6 2006/08/29 07:41:46 swildner Exp $ +# @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# This file specifies various information about terminals on the system. +# It is used by several different programs. Common entries for the +# various columns include: +# +# name The name of the terminal device. +# +# getty The program to start running on the terminal. Typically a +# getty program, as the name implies. Other common entries +# include none, when no getty is needed, and xdm, to start the +# X Window System. +# +# type The initial terminal type for this port. For hardwired +# terminal lines, this will contain the type of terminal used. +# For virtual consoles, the correct type is cons25. Other +# common values include network for network connections on +# pseudo-terminals, dialup for incoming modem ports, and unknown +# when the terminal type cannot be predetermined. +# +# status Must be on or off. If on, init will run the getty program on +# the specified port. If the word "secure" appears, this tty +# allows root login. +# +# name getty type status comments +# +# If console is marked "insecure", then init will ask for the root password +# when going to single-user mode. +console none unknown off secure +# +ttyv0 "/usr/libexec/getty Pc" cons25 on secure +# Virtual terminals +ttyv1 "/usr/libexec/getty Pc" cons25 on secure +ttyv2 "/usr/libexec/getty Pc" cons25 on secure +ttyv3 "/usr/libexec/getty Pc" cons25 on secure +ttyv4 "/usr/libexec/getty Pc" cons25 on secure +ttyv5 "/usr/libexec/getty Pc" cons25 on secure +ttyv6 "/usr/libexec/getty Pc" cons25 on secure +ttyv7 "/usr/libexec/getty Pc" cons25 on secure +ttyv8 "/usr/pkg/xorg/bin/xdm -nodaemon" xterm off secure +# Serial terminals +# The 'dialup' keyword identifies dialin lines to login, fingerd etc. +ttyd0 "/usr/libexec/getty std.9600" dialup off secure +ttyd1 "/usr/libexec/getty std.9600" dialup off secure +ttyd2 "/usr/libexec/getty std.9600" dialup off secure +ttyd3 "/usr/libexec/getty std.9600" dialup off secure +# Dumb console +dcons "/usr/libexec/getty std.9600" vt100 off secure +# Pseudo terminals +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttypg none network +ttyph none network +ttypi none network +ttypj none network +ttypk none network +ttypl none network +ttypm none network +ttypn none network +ttypo none network +ttypp none network +ttypq none network +ttypr none network +ttyps none network +ttypt none network +ttypu none network +ttypv none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network +ttyqg none network +ttyqh none network +ttyqi none network +ttyqj none network +ttyqk none network +ttyql none network +ttyqm none network +ttyqn none network +ttyqo none network +ttyqp none network +ttyqq none network +ttyqr none network +ttyqs none network +ttyqt none network +ttyqu none network +ttyqv none network +ttyr0 none network +ttyr1 none network +ttyr2 none network +ttyr3 none network +ttyr4 none network +ttyr5 none network +ttyr6 none network +ttyr7 none network +ttyr8 none network +ttyr9 none network +ttyra none network +ttyrb none network +ttyrc none network +ttyrd none network +ttyre none network +ttyrf none network +ttyrg none network +ttyrh none network +ttyri none network +ttyrj none network +ttyrk none network +ttyrl none network +ttyrm none network +ttyrn none network +ttyro none network +ttyrp none network +ttyrq none network +ttyrr none network +ttyrs none network +ttyrt none network +ttyru none network +ttyrv none network +ttys0 none network +ttys1 none network +ttys2 none network +ttys3 none network +ttys4 none network +ttys5 none network +ttys6 none network +ttys7 none network +ttys8 none network +ttys9 none network +ttysa none network +ttysb none network +ttysc none network +ttysd none network +ttyse none network +ttysf none network +ttysg none network +ttysh none network +ttysi none network +ttysj none network +ttysk none network +ttysl none network +ttysm none network +ttysn none network +ttyso none network +ttysp none network +ttysq none network +ttysr none network +ttyss none network +ttyst none network +ttysu none network +ttysv none network +ttyP0 none network +ttyP1 none network +ttyP2 none network +ttyP3 none network +ttyP4 none network +ttyP5 none network +ttyP6 none network +ttyP7 none network +ttyP8 none network +ttyP9 none network +ttyPa none network +ttyPb none network +ttyPc none network +ttyPd none network +ttyPe none network +ttyPf none network +ttyPg none network +ttyPh none network +ttyPi none network +ttyPj none network +ttyPk none network +ttyPl none network +ttyPm none network +ttyPn none network +ttyPo none network +ttyPp none network +ttyPq none network +ttyPr none network +ttyPs none network +ttyPt none network +ttyPu none network +ttyPv none network +ttyQ0 none network +ttyQ1 none network +ttyQ2 none network +ttyQ3 none network +ttyQ4 none network +ttyQ5 none network +ttyQ6 none network +ttyQ7 none network +ttyQ8 none network +ttyQ9 none network +ttyQa none network +ttyQb none network +ttyQc none network +ttyQd none network +ttyQe none network +ttyQf none network +ttyQg none network +ttyQh none network +ttyQi none network +ttyQj none network +ttyQk none network +ttyQl none network +ttyQm none network +ttyQn none network +ttyQo none network +ttyQp none network +ttyQq none network +ttyQr none network +ttyQs none network +ttyQt none network +ttyQu none network +ttyQv none network +ttyR0 none network +ttyR1 none network +ttyR2 none network +ttyR3 none network +ttyR4 none network +ttyR5 none network +ttyR6 none network +ttyR7 none network +ttyR8 none network +ttyR9 none network +ttyRa none network +ttyRb none network +ttyRc none network +ttyRd none network +ttyRe none network +ttyRf none network +ttyRg none network +ttyRh none network +ttyRi none network +ttyRj none network +ttyRk none network +ttyRl none network +ttyRm none network +ttyRn none network +ttyRo none network +ttyRp none network +ttyRq none network +ttyRr none network +ttyRs none network +ttyRt none network +ttyRu none network +ttyRv none network +ttyS0 none network +ttyS1 none network +ttyS2 none network +ttyS3 none network +ttyS4 none network +ttyS5 none network +ttyS6 none network +ttyS7 none network +ttyS8 none network +ttyS9 none network +ttySa none network +ttySb none network +ttySc none network +ttySd none network +ttySe none network +ttySf none network +ttySg none network +ttySh none network +ttySi none network +ttySj none network +ttySk none network +ttySl none network +ttySm none network +ttySn none network +ttySo none network +ttySp none network +ttySq none network +ttySr none network +ttySs none network +ttySt none network +ttySu none network +ttySv none network diff --git a/sys/bus/pci/pci.c b/sys/bus/pci/pci.c index cea617421c..36aa3bc4a1 100644 --- a/sys/bus/pci/pci.c +++ b/sys/bus/pci/pci.c @@ -2119,7 +2119,7 @@ pci_alloc_resource(device_t dev, device_t child, int type, int *rid, if (device_get_parent(child) == dev) { switch (type) { case SYS_RES_IRQ: -#ifdef __i386__ +#if defined(__i386__) || defined(__amd64__) /* * If device doesn't have an interrupt routed, and is * deserving of an interrupt, try to assign it one. diff --git a/sys/conf/files b/sys/conf/files index 977f645352..ea8cc475bb 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1538,8 +1538,6 @@ emulation/43bsd/43bsd_exit.c optional compat_43 emulation/43bsd/43bsd_resource.c optional compat_43 emulation/43bsd/43bsd_hostinfo.c optional compat_43 emulation/43bsd/43bsd_vm.c optional compat_43 -emulation/dragonfly12/dfbsd12_getdirentries.c nonoptional compat_df12 -emulation/dragonfly12/dfbsd12_stat.c nonoptional compat_df12 # OS ACPI MI code ${OSACPI_MI_DIR}/acpi.c optional acpi diff --git a/sys/config/AMD64_GENERIC b/sys/config/AMD64_GENERIC index 635df6abee..17ba811b23 100644 --- a/sys/config/AMD64_GENERIC +++ b/sys/config/AMD64_GENERIC @@ -63,7 +63,7 @@ options DDB options DDB_TRACE options INVARIANTS -#device isa +device isa #device eisa #device pci @@ -112,10 +112,10 @@ device npx0 at nexus? port IO_NPX irq 13 # device apm0 at nexus? disable flags 0x20 # Advanced Power Management # Serial (COM) ports -#device sio0 at isa? port IO_COM1 flags 0x10 irq 4 -#device sio1 at isa? port IO_COM2 irq 3 -#device sio2 at isa? disable port IO_COM3 irq 5 -#device sio3 at isa? disable port IO_COM4 irq 9 +device sio0 at isa? port IO_COM1 flags 0x10 irq 4 +device sio1 at isa? port IO_COM2 irq 3 +device sio2 at isa? disable port IO_COM3 irq 5 +device sio3 at isa? disable port IO_COM4 irq 9 # Parallel port #device ppc0 at isa? irq 7 diff --git a/sys/cpu/amd64/include/atomic.h b/sys/cpu/amd64/include/atomic.h index 8e344c3d54..25eff346e1 100644 --- a/sys/cpu/amd64/include/atomic.h +++ b/sys/cpu/amd64/include/atomic.h @@ -244,7 +244,8 @@ atomic_intr_cond_enter(atomic_intr_t *p, void (*func)(void *), void *arg) "2: ;" \ : "+m" (*p) \ : "r"(func), "m"(arg) \ - : "ax", "cx", "dx", "di"); /* XXX clobbers more regs */ + : "ax", "cx", "dx", "rsi", "rdi", "r8", "r9", "r10", "r11"); + /* YYY the function call may clobber even more registers? */ } /* diff --git a/sys/cpu/amd64/misc/amd64-gdbstub.c b/sys/cpu/amd64/misc/amd64-gdbstub.c index 06ba3c11dd..b4beae852e 100644 --- a/sys/cpu/amd64/misc/amd64-gdbstub.c +++ b/sys/cpu/amd64/misc/amd64-gdbstub.c @@ -454,9 +454,9 @@ gdb_handle_exception (db_regs_t *raw_regs, int type, int code) char * ptr; struct amd64regs { unsigned long rax; + unsigned long rbx; unsigned long rcx; unsigned long rdx; - unsigned long rbx; unsigned long rsi; unsigned long rdi; unsigned long rbp; diff --git a/sys/dev/misc/syscons/syscons.c b/sys/dev/misc/syscons/syscons.c index 9994b31348..4512935ee4 100644 --- a/sys/dev/misc/syscons/syscons.c +++ b/sys/dev/misc/syscons/syscons.c @@ -35,7 +35,9 @@ #include "use_splash.h" #include "opt_syscons.h" #include "opt_ddb.h" +#ifdef __i386__ #include "use_apm.h" +#endif #include #include @@ -55,7 +57,9 @@ #include #include #include +#ifdef __i386__ #include +#endif #include #include @@ -1007,11 +1011,19 @@ scioctl(struct dev_ioctl_args *ap) return error; if (securelevel > 0) return EPERM; +#if defined(__i386__) curthread->td_lwp->lwp_md.md_regs->tf_eflags |= PSL_IOPL; +#elif defined(__amd64__) + curthread->td_lwp->lwp_md.md_regs->tf_rflags |= PSL_IOPL; +#endif return 0; case KDDISABIO: /* disallow io operations (default) */ +#if defined(__i386__) curthread->td_lwp->lwp_md.md_regs->tf_eflags &= ~PSL_IOPL; +#elif defined(__amd64__) + curthread->td_lwp->lwp_md.md_regs->tf_rflags &= ~PSL_IOPL; +#endif return 0; case KDSKBSTATE: /* set keyboard state (locks) */ diff --git a/sys/dev/video/fb/fbreg.h b/sys/dev/video/fb/fbreg.h index 4a15c382cf..768cf1af75 100644 --- a/sys/dev/video/fb/fbreg.h +++ b/sys/dev/video/fb/fbreg.h @@ -35,7 +35,7 @@ #define V_MAX_ADAPTERS 8 /* XXX */ /* some macros */ -#ifdef __i386__ +#if defined(__i386__) || defined(__amd64__) #define bcopy_io(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c)) #define bcopy_toio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c)) #define bcopy_fromio(s, d, c) generic_bcopy((void *)(s), (void *)(d), (c)) diff --git a/sys/dev/video/fb/vga.c b/sys/dev/video/fb/vga.c index ece82bb621..fe5bc18485 100644 --- a/sys/dev/video/fb/vga.c +++ b/sys/dev/video/fb/vga.c @@ -46,7 +46,9 @@ #include #include +#ifdef __i386__ #include +#endif #include #include @@ -59,6 +61,10 @@ #define VGA_DEBUG 0 #endif +/* machine/pc/bios.h has got too much i386-specific stuff in it */ +#ifndef BIOS_PADDRTOVADDR +#define BIOS_PADDRTOVADDR(x) (((x) - ISA_HOLE_START) + atdevbase) +#endif int vga_probe_unit(int unit, video_adapter_t *buf, int flags) { @@ -904,7 +910,7 @@ set_display_start(video_adapter_t *adp, int x, int y) } #ifndef VGA_NO_MODE_CHANGE -#ifdef __i386__ /* XXX */ +#if defined(__i386__) || defined(__amd64__) /* XXX */ static void fill(int val, void *d, size_t size) { @@ -913,7 +919,7 @@ fill(int val, void *d, size_t size) while (size-- > 0) *p++ = val; } -#endif /* __i386__ */ +#endif /* __i386__ || __amd64__ */ static void filll_io(int val, vm_offset_t d, size_t size) @@ -1370,10 +1376,10 @@ vga_save_font(video_adapter_t *adp, int page, int fontsize, u_char *data, set_font_mode(adp, buf); if (fontsize == 32) { - bcopy_fromio(segment + ch*32, data, fontsize*count); + bcopy_fromio((uintptr_t)segment + ch*32, data, fontsize*count); } else { for (c = ch; count > 0; ++c, --count) { - bcopy_fromio(segment + c*32, data, fontsize); + bcopy_fromio((uintptr_t)segment + c*32, data, fontsize); data += fontsize; } } @@ -1443,10 +1449,10 @@ vga_load_font(video_adapter_t *adp, int page, int fontsize, u_char *data, set_font_mode(adp, buf); if (fontsize == 32) { - bcopy_toio(data, segment + ch*32, fontsize*count); + bcopy_toio(data, (uintptr_t)segment + ch*32, fontsize*count); } else { for (c = ch; count > 0; ++c, --count) { - bcopy_toio(data, segment + c*32, fontsize); + bcopy_toio(data, (uintptr_t)segment + c*32, fontsize); data += fontsize; } } diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 0075c19bf0..24450a636a 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -194,6 +194,8 @@ mi_startup(void) struct sysinit **xipp; /* interior loop of sort*/ struct sysinit *save; /* bubble*/ + //kprintf0("mi_startup\n"); + if (sysinit == NULL) { sysinit = SET_BEGIN(sysinit_set); sysinit_end = SET_LIMIT(sysinit_set); @@ -231,6 +233,8 @@ restart: if (sip->subsystem == SI_SPECIAL_DONE) continue; + //kprintf0("!%s!", sip->name); + /* Call function */ (*(sip->func))(sip->udata); diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 016fac200a..1ada7b9e1a 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -431,6 +431,57 @@ ktr_resync_callback(void *dummy __unused) /* * KTR_WRITE_ENTRY - Primary entry point for kernel trace logging */ + +void +ktr_write_str_entry(struct ktr_info *info, const char *file, int line, const char *jg_format, ...) +{ + __va_list va; + struct ktr_entry *entry; + int cpu; + __va_start(va, jg_format); + + cpu = mycpu->gd_cpuid; + if (!ktr_buf[cpu]) + return; + + crit_enter(); + entry = ktr_buf[cpu] + (ktr_idx[cpu] & KTR_ENTRIES_MASK); + ++ktr_idx[cpu]; +#ifdef _RDTSC_SUPPORTED_ + if (cpu_feature & CPUID_TSC) { +#ifdef SMP + entry->ktr_timestamp = rdtsc() - tsc_offsets[cpu]; +#else + entry->ktr_timestamp = rdtsc(); +#endif + } else +#endif + { + entry->ktr_timestamp = get_approximate_time_t(); + } + entry->ktr_info = info; + entry->ktr_file = file; + entry->ktr_line = line; + crit_exit(); + kvsnprintf(entry->ktr_data, KTR_BUFSIZE, jg_format, va); + ((char *)(entry->ktr_data))[KTR_BUFSIZE - 1] = '\0'; + if (ktr_stacktrace) + cpu_ktr_caller(entry); +#ifdef KTR_VERBOSE + if (ktr_verbose && info->kf_format) { +#ifdef SMP + kprintf("cpu%d ", cpu); +#endif + if (ktr_verbose > 1) { + kprintf("%s.%d\t", entry->ktr_file, entry->ktr_line); + } + kvprintf(info->kf_format, ptr); + kprintf("\n"); + } +#endif + __va_end(va); +} + static __inline void ktr_write_entry(struct ktr_info *info, const char *file, int line, @@ -463,9 +514,9 @@ ktr_write_entry(struct ktr_info *info, const char *file, int line, entry->ktr_line = line; crit_exit(); if (info->kf_data_size > KTR_BUFSIZE) - bcopyi(ptr, entry->ktr_data, KTR_BUFSIZE); + bcopy(ptr, entry->ktr_data, KTR_BUFSIZE); else if (info->kf_data_size) - bcopyi(ptr, entry->ktr_data, info->kf_data_size); + bcopy(ptr, entry->ktr_data, info->kf_data_size); if (ktr_stacktrace) cpu_ktr_caller(entry); #ifdef KTR_VERBOSE @@ -626,11 +677,15 @@ db_mach_vtrace(int cpu, struct ktr_entry *kp, int idx) db_printf("%s\t", kp->ktr_info->kf_name); db_printf("from(%p,%p) ", kp->ktr_caller1, kp->ktr_caller2); if (kp->ktr_info->kf_format) { - int32_t *args = kp->ktr_data; - db_printf(kp->ktr_info->kf_format, - args[0], args[1], args[2], args[3], - args[4], args[5], args[6], args[7], - args[8], args[9], args[10], args[11]); + if (strcmp(kp->ktr_info->kf_format, "STR") == 0) { + db_printf("%s", kp->ktr_data); + } else { + int64_t *args = kp->ktr_data; + db_printf(kp->ktr_info->kf_format, + args[0], args[1], args[2], args[3], + args[4], args[5], args[6], args[7], + args[8], args[9], args[10], args[11]); + } } db_printf("\n"); diff --git a/sys/kern/lwkt_thread.c b/sys/kern/lwkt_thread.c index 25aa40acd4..a1ce259196 100644 --- a/sys/kern/lwkt_thread.c +++ b/sys/kern/lwkt_thread.c @@ -95,6 +95,27 @@ static struct objcache *thread_cache; volatile cpumask_t mp_lock_contention_mask; +extern void cpu_heavy_restore(void); +extern void cpu_lwkt_restore(void); +extern void cpu_kthread_restore(void); +extern void cpu_idle_restore(void); + +int +jg_tos_ok(struct thread *td) +{ + if (td == NULL) { + return 1; + } + KKASSERT(td->td_sp != NULL); + unsigned long tos = ((unsigned long *)td->td_sp)[0]; + int tos_ok = 0; + if ((tos == cpu_heavy_restore) || (tos == cpu_lwkt_restore) + || (tos == cpu_kthread_restore) || (tos == cpu_idle_restore)) { + tos_ok = 1; + } + return tos_ok; +} + /* * We can make all thread ports use the spin backend instead of the thread * backend. This should only be set to debug the spin backend. @@ -745,6 +766,7 @@ using_idle_thread: #endif if (td != ntd) { ++switch_count; + KKASSERT(jg_tos_ok(ntd)); td->td_switch(ntd); } /* NOTE: current cpu may have changed after switch */ diff --git a/sys/platform/pc32/conf/files b/sys/platform/pc32/conf/files index c1e7c9853b..1e6d5f19cb 100644 --- a/sys/platform/pc32/conf/files +++ b/sys/platform/pc32/conf/files @@ -35,6 +35,9 @@ ukbdmap.h optional ukbd_dflt_keymap \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # +emulation/dragonfly12/dfbsd12_getdirentries.c nonoptional compat_df12 +emulation/dragonfly12/dfbsd12_stat.c nonoptional compat_df12 +# hal.o optional ath_hal \ dependency "$S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ compile-with "uudecode < $S/contrib/dev/ath/public/i386-elf.hal.o.uu" \ diff --git a/sys/platform/pc64/amd64/genassym.c b/sys/platform/pc64/amd64/genassym.c index 64303b4636..df64c124f4 100644 --- a/sys/platform/pc64/amd64/genassym.c +++ b/sys/platform/pc64/amd64/genassym.c @@ -117,6 +117,15 @@ ASSYM(PCB_RBP, offsetof(struct pcb, pcb_rbp)); ASSYM(PCB_RSP, offsetof(struct pcb, pcb_rsp)); ASSYM(PCB_RBX, offsetof(struct pcb, pcb_rbx)); ASSYM(PCB_RIP, offsetof(struct pcb, pcb_rip)); +ASSYM(TSS_RSP0, offsetof(struct amd64tss, tss_rsp0)); + +ASSYM(PCB_DR0, offsetof(struct pcb, pcb_dr0)); +ASSYM(PCB_DR1, offsetof(struct pcb, pcb_dr1)); +ASSYM(PCB_DR2, offsetof(struct pcb, pcb_dr2)); +ASSYM(PCB_DR3, offsetof(struct pcb, pcb_dr3)); +ASSYM(PCB_DR6, offsetof(struct pcb, pcb_dr6)); +ASSYM(PCB_DR7, offsetof(struct pcb, pcb_dr7)); +ASSYM(PCB_DBREGS, PCB_DBREGS); ASSYM(PCB_EXT, offsetof(struct pcb, pcb_ext)); ASSYM(PCB_FULLCTX, PCB_FULLCTX); ASSYM(PCB_FLAGS, offsetof(struct pcb, pcb_flags)); diff --git a/sys/platform/pc64/amd64/machdep.c b/sys/platform/pc64/amd64/machdep.c index 6065f0bf89..7879650542 100644 --- a/sys/platform/pc64/amd64/machdep.c +++ b/sys/platform/pc64/amd64/machdep.c @@ -1101,7 +1101,7 @@ exec_setregs(u_long entry, u_long stack, u_long ps_strings) pcb->pcb_dr2 = 0; pcb->pcb_dr3 = 0; pcb->pcb_dr6 = 0; - pcb->pcb_dr7 = 0; + pcb->pcb_dr7 = 0; /* JG set bit 10? */ if (pcb == td->td_pcb) { /* * Clear the debug registers on the running @@ -2159,30 +2159,26 @@ int fill_dbregs(struct lwp *lp, struct dbreg *dbregs) { if (lp == NULL) { -#if JG - dbregs->dr0 = rdr0(); - dbregs->dr1 = rdr1(); - dbregs->dr2 = rdr2(); - dbregs->dr3 = rdr3(); - dbregs->dr4 = rdr4(); - dbregs->dr5 = rdr5(); - dbregs->dr6 = rdr6(); - dbregs->dr7 = rdr7(); -#endif + dbregs->dr[0] = rdr0(); + dbregs->dr[1] = rdr1(); + dbregs->dr[2] = rdr2(); + dbregs->dr[3] = rdr3(); + dbregs->dr[4] = rdr4(); + dbregs->dr[5] = rdr5(); + dbregs->dr[6] = rdr6(); + dbregs->dr[7] = rdr7(); } else { struct pcb *pcb; pcb = lp->lwp_thread->td_pcb; -#if JG - dbregs->dr0 = pcb->pcb_dr0; - dbregs->dr1 = pcb->pcb_dr1; - dbregs->dr2 = pcb->pcb_dr2; - dbregs->dr3 = pcb->pcb_dr3; - dbregs->dr4 = 0; - dbregs->dr5 = 0; - dbregs->dr6 = pcb->pcb_dr6; - dbregs->dr7 = pcb->pcb_dr7; -#endif + dbregs->dr[0] = pcb->pcb_dr0; + dbregs->dr[1] = pcb->pcb_dr1; + dbregs->dr[2] = pcb->pcb_dr2; + dbregs->dr[3] = pcb->pcb_dr3; + dbregs->dr[4] = 0; + dbregs->dr[5] = 0; + dbregs->dr[6] = pcb->pcb_dr6; + dbregs->dr[7] = pcb->pcb_dr7; } return (0); } @@ -2191,21 +2187,19 @@ int set_dbregs(struct lwp *lp, struct dbreg *dbregs) { if (lp == NULL) { -#if JG - load_dr0(dbregs->dr0); - load_dr1(dbregs->dr1); - load_dr2(dbregs->dr2); - load_dr3(dbregs->dr3); - load_dr4(dbregs->dr4); - load_dr5(dbregs->dr5); - load_dr6(dbregs->dr6); - load_dr7(dbregs->dr7); -#endif + load_dr0(dbregs->dr[0]); + load_dr1(dbregs->dr[1]); + load_dr2(dbregs->dr[2]); + load_dr3(dbregs->dr[3]); + load_dr4(dbregs->dr[4]); + load_dr5(dbregs->dr[5]); + load_dr6(dbregs->dr[6]); + load_dr7(dbregs->dr[7]); } else { struct pcb *pcb; struct ucred *ucred; int i; - uint32_t mask1, mask2; + uint64_t mask1, mask2; /* * Don't let an illegal value for dr7 get set. Specifically, @@ -2213,12 +2207,20 @@ set_dbregs(struct lwp *lp, struct dbreg *dbregs) * result in undefined behaviour and can lead to an unexpected * TRCTRAP. */ - for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 8; - i++, mask1 <<= 2, mask2 <<= 2) -#if JG - if ((dbregs->dr7 & mask1) == mask2) + /* JG this loop looks unreadable */ + /* Check 4 2-bit fields for invalid patterns. + * These fields are R/Wi, for i = 0..3 + */ + /* Is 10 in LENi allowed when running in compatibility mode? */ + /* Pattern 10 in R/Wi might be used to indicate + * breakpoint on I/O. Further analysis should be + * carried to decide if it is safe and useful to + * provide access to that capability + */ + for (i = 0, mask1 = 0x3<<16, mask2 = 0x2<<16; i < 4; + i++, mask1 <<= 4, mask2 <<= 4) + if ((dbregs->dr[7] & mask1) == mask2) return (EINVAL); -#endif pcb = lp->lwp_thread->td_pcb; ucred = lp->lwp_proc->p_ucred; @@ -2239,41 +2241,37 @@ set_dbregs(struct lwp *lp, struct dbreg *dbregs) */ if (suser_cred(ucred, 0) != 0) { -#if JG - if (dbregs->dr7 & 0x3) { + if (dbregs->dr[7] & 0x3) { /* dr0 is enabled */ - if (dbregs->dr0 >= VM_MAX_USER_ADDRESS) + if (dbregs->dr[0] >= VM_MAX_USER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<2)) { + if (dbregs->dr[7] & (0x3<<2)) { /* dr1 is enabled */ - if (dbregs->dr1 >= VM_MAX_USER_ADDRESS) + if (dbregs->dr[1] >= VM_MAX_USER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<4)) { + if (dbregs->dr[7] & (0x3<<4)) { /* dr2 is enabled */ - if (dbregs->dr2 >= VM_MAX_USER_ADDRESS) + if (dbregs->dr[2] >= VM_MAX_USER_ADDRESS) return (EINVAL); } - if (dbregs->dr7 & (0x3<<6)) { + if (dbregs->dr[7] & (0x3<<6)) { /* dr3 is enabled */ - if (dbregs->dr3 >= VM_MAX_USER_ADDRESS) + if (dbregs->dr[3] >= VM_MAX_USER_ADDRESS) return (EINVAL); } -#endif } -#if JG - pcb->pcb_dr0 = dbregs->dr0; - pcb->pcb_dr1 = dbregs->dr1; - pcb->pcb_dr2 = dbregs->dr2; - pcb->pcb_dr3 = dbregs->dr3; - pcb->pcb_dr6 = dbregs->dr6; - pcb->pcb_dr7 = dbregs->dr7; -#endif + pcb->pcb_dr0 = dbregs->dr[0]; + pcb->pcb_dr1 = dbregs->dr[1]; + pcb->pcb_dr2 = dbregs->dr[2]; + pcb->pcb_dr3 = dbregs->dr[3]; + pcb->pcb_dr6 = dbregs->dr[6]; + pcb->pcb_dr7 = dbregs->dr[7]; pcb->pcb_flags |= PCB_DBREGS; } @@ -2288,14 +2286,14 @@ set_dbregs(struct lwp *lp, struct dbreg *dbregs) int user_dbreg_trap(void) { - u_int32_t dr7, dr6; /* debug registers dr6 and dr7 */ - u_int32_t bp; /* breakpoint bits extracted from dr6 */ + u_int64_t dr7, dr6; /* debug registers dr6 and dr7 */ + u_int64_t bp; /* breakpoint bits extracted from dr6 */ int nbp; /* number of breakpoints that triggered */ caddr_t addr[4]; /* breakpoint addresses */ int i; dr7 = rdr7(); - if ((dr7 & 0x000000ff) == 0) { + if ((dr7 & 0xff) == 0) { /* * all GE and LE bits in the dr7 register are zero, * thus the trap couldn't have been caused by the @@ -2306,9 +2304,9 @@ user_dbreg_trap(void) nbp = 0; dr6 = rdr6(); - bp = dr6 & 0x0000000f; + bp = dr6 & 0xf; - if (!bp) { + if (bp == 0) { /* * None of the breakpoint bits are set meaning this * trap was not caused by any of the debug registers diff --git a/sys/platform/pc64/amd64/nexus.c b/sys/platform/pc64/amd64/nexus.c index 9dba3d15d1..1f92707ea8 100644 --- a/sys/platform/pc64/amd64/nexus.c +++ b/sys/platform/pc64/amd64/nexus.c @@ -567,6 +567,7 @@ static void PCHAR_(int); int kprintf0(const char *fmt, ...) { + return 0; __va_list ap; int retval; diff --git a/sys/platform/pc64/amd64/support.s b/sys/platform/pc64/amd64/support.s index 3bb5f99f7e..b19e4e3307 100644 --- a/sys/platform/pc64/amd64/support.s +++ b/sys/platform/pc64/amd64/support.s @@ -109,6 +109,8 @@ ENTRY(bcmp) * rdi, rsi, rdx * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 */ +ENTRY(generic_bcopy) /* generic_bcopy is bcopy without FPU */ +ENTRY(ovbcopy) /* our bcopy doesn't use the FPU, so ovbcopy is the same */ ENTRY(bcopy) xchgq %rsi,%rdi movq %rdx,%rcx @@ -146,11 +148,15 @@ ENTRY(bcopy) movsq cld ret -ENTRY(ovbcopy) - ud2 - ret ENTRY(reset_dbregs) - ud2 + movq $0x200,%rax /* the manual says that bit 10 must be set to 1 */ + movq %rax,%dr7 /* disable all breapoints first */ + movq $0,%rax + movq %rax,%dr0 + movq %rax,%dr1 + movq %rax,%dr2 + movq %rax,%dr3 + movq %rax,%dr6 ret /* diff --git a/sys/platform/pc64/amd64/swtch.s b/sys/platform/pc64/amd64/swtch.s index f966c882c4..3a5b07edb5 100644 --- a/sys/platform/pc64/amd64/swtch.s +++ b/sys/platform/pc64/amd64/swtch.s @@ -153,29 +153,28 @@ ENTRY(cpu_heavy_switch) pushq %rax movq %rsp,TD_SP(%rbx) -#if JG /* * Save debug regs if necessary */ - movb PCB_FLAGS(%edx),%al - andb $PCB_DBREGS,%al + movq PCB_FLAGS(%rdx),%rax + andq $PCB_DBREGS,%rax jz 1f /* no, skip over */ - movl %dr7,%eax /* yes, do the save */ - movl %eax,PCB_DR7(%edx) - andl $0x0000fc00, %eax /* disable all watchpoints */ - movl %eax,%dr7 - movl %dr6,%eax - movl %eax,PCB_DR6(%edx) - movl %dr3,%eax - movl %eax,PCB_DR3(%edx) - movl %dr2,%eax - movl %eax,PCB_DR2(%edx) - movl %dr1,%eax - movl %eax,PCB_DR1(%edx) - movl %dr0,%eax - movl %eax,PCB_DR0(%edx) + movq %dr7,%rax /* yes, do the save */ + movq %rax,PCB_DR7(%rdx) + /* JG correct value? */ + andq $0x0000fc00, %rax /* disable all watchpoints */ + movq %rax,%dr7 + movq %dr6,%rax + movq %rax,PCB_DR6(%rdx) + movq %dr3,%rax + movq %rax,PCB_DR3(%rdx) + movq %dr2,%rax + movq %rax,PCB_DR2(%rdx) + movq %dr1,%rax + movq %rax,PCB_DR1(%rdx) + movq %dr0,%rax + movq %rax,PCB_DR0(%rdx) 1: -#endif #if JG #if NNPX > 0 @@ -364,10 +363,11 @@ ENTRY(cpu_heavy_restore) * usermode. The PCB is at the top of the stack but we need another * 16 bytes to take vm86 into account. */ -#if JG - leal -16(%edx),%ebx - movl %ebx, PCPU(common_tss) + TSS_ESP0 + leaq -16(%rdx),%rbx + movq %rbx, PCPU(common_tss) + TSS_RSP0 + movq %rbx, PCPU(rsp0) +#if JG cmpl $0,PCPU(private_tss) /* don't have to reload if */ je 3f /* already using the common TSS */ @@ -465,33 +465,34 @@ ENTRY(cpu_heavy_restore) popl %edx #endif -#if JG /* * Restore the DEBUG register state if necessary. */ - movb PCB_FLAGS(%edx),%al - andb $PCB_DBREGS,%al + movq PCB_FLAGS(%rdx),%rax + andq $PCB_DBREGS,%rax jz 1f /* no, skip over */ - movl PCB_DR6(%edx),%eax /* yes, do the restore */ - movl %eax,%dr6 - movl PCB_DR3(%edx),%eax - movl %eax,%dr3 - movl PCB_DR2(%edx),%eax - movl %eax,%dr2 - movl PCB_DR1(%edx),%eax - movl %eax,%dr1 - movl PCB_DR0(%edx),%eax - movl %eax,%dr0 - movl %dr7,%eax /* load dr7 so as not to disturb */ - andl $0x0000fc00,%eax /* reserved bits */ - pushl %ebx - movl PCB_DR7(%edx),%ebx - andl $~0x0000fc00,%ebx - orl %ebx,%eax - popl %ebx - movl %eax,%dr7 + movq PCB_DR6(%rdx),%rax /* yes, do the restore */ + movq %rax,%dr6 + movq PCB_DR3(%rdx),%rax + movq %rax,%dr3 + movq PCB_DR2(%rdx),%rax + movq %rax,%dr2 + movq PCB_DR1(%rdx),%rax + movq %rax,%dr1 + movq PCB_DR0(%rdx),%rax + movq %rax,%dr0 + movq %dr7,%rax /* load dr7 so as not to disturb */ + /* JG correct value? */ + andq $0x0000fc00,%rax /* reserved bits */ + /* JG we've got more registers on amd64 */ + pushq %rbx + movq PCB_DR7(%rdx),%rbx + /* JG correct value? */ + andq $~0x0000fc00,%rbx + orq %rbx,%rax + popq %rbx + movq %rax,%dr7 1: -#endif CHECKNZ((%rsp), %r9) ret diff --git a/sys/platform/pc64/amd64/trap.c b/sys/platform/pc64/amd64/trap.c index 17d6836a9f..4c10823aa1 100644 --- a/sys/platform/pc64/amd64/trap.c +++ b/sys/platform/pc64/amd64/trap.c @@ -345,6 +345,21 @@ userexit(struct lwp *lp) td->td_release = NULL; } +#if !defined(KTR_KERNENTRY) +#define KTR_KERNENTRY KTR_ALL +#endif +KTR_INFO_MASTER(kernentry); +KTR_INFO(KTR_KERNENTRY, kernentry, trap, 0, "STR", + sizeof(long) + sizeof(long) + sizeof(long) + sizeof(vm_offset_t)); +KTR_INFO(KTR_KERNENTRY, kernentry, trap_ret, 0, "STR", + sizeof(long) + sizeof(long)); +KTR_INFO(KTR_KERNENTRY, kernentry, syscall, 0, "STR", + sizeof(long) + sizeof(long) + sizeof(long)); +KTR_INFO(KTR_KERNENTRY, kernentry, syscall_ret, 0, "STR", + sizeof(long) + sizeof(long) + sizeof(long)); +KTR_INFO(KTR_KERNENTRY, kernentry, fork_ret, 0, "STR", + sizeof(long) + sizeof(long)); + /* * Exception, fault, and trap interface to the kernel. * This common code is called from assembly language IDT gate entry @@ -455,8 +470,13 @@ trap(struct trapframe *frame) if (ISPL(frame->tf_cs) == SEL_UPL) { /* user trap */ +#if JG KTR_LOG(kernentry_trap, p->p_pid, lp->lwp_tid, frame->tf_trapno, eva); +#else + KTR_LOG_STR(kernentry_trap, "pid=%d, tid=%d, trapno=%ld, eva=%lx", p->p_pid, lp->lwp_tid, + frame->tf_trapno, (frame->tf_trapno == T_PAGEFLT ? frame->tf_addr : 0)); +#endif userenter(td); @@ -510,7 +530,7 @@ trap(struct trapframe *frame) case T_PAGEFLT: /* page fault */ MAKEMPSAFE(have_mplock); i = trap_pfault(frame, TRUE); - kprintf("TRAP_PFAULT %d\n", i); + //kprintf("TRAP_PFAULT %d\n", i); if (frame->tf_rip == 0) Debugger("debug"); if (i == -1) @@ -791,7 +811,11 @@ out2: ; rel_mplock(); #endif if (p != NULL && lp != NULL) +#if JG KTR_LOG(kernentry_trap_ret, p->p_pid, lp->lwp_tid); +#else + KTR_LOG_STR(kernentry_trap_ret, "pid=%d, tid=%d", p->p_pid, lp->lwp_tid); +#endif #ifdef INVARIANTS KASSERT(crit_count == (td->td_pri & ~TDPRI_MASK), ("syscall: critical section count mismatch! %d/%d", @@ -1057,8 +1081,13 @@ syscall2(struct trapframe *frame) } #endif +#if JG KTR_LOG(kernentry_syscall, p->p_pid, lp->lwp_tid, frame->tf_eax); +#else + KTR_LOG_STR(kernentry_syscall, "pid=%d, tid=%d, call=%ld", p->p_pid, lp->lwp_tid, + frame->tf_rax); +#endif #ifdef SMP KASSERT(td->td_mpcount == 0, ("badmpcount syscall2 from %p", (void *)frame->tf_eip)); @@ -1192,7 +1221,7 @@ out: /* * MP SAFE (we may or may not have the MP lock at this point) */ - kprintf("SYSMSG %d ", error); + //kprintf("SYSMSG %d ", error); switch (error) { case 0: /* @@ -1273,7 +1302,11 @@ bad: if (have_mplock) rel_mplock(); #endif +#if JG KTR_LOG(kernentry_syscall_ret, p->p_pid, lp->lwp_tid, error); +#else + KTR_LOG_STR(kernentry_syscall_ret, "pid=%d, tid=%d, err=%d", p->p_pid, lp->lwp_tid, error); +#endif #ifdef INVARIANTS KASSERT(crit_count == (td->td_pri & ~TDPRI_MASK), ("syscall: critical section count mismatch! %d/%d", @@ -1290,7 +1323,11 @@ fork_return(struct lwp *lp, struct trapframe *frame) frame->tf_rdx = 1; generic_lwp_return(lp, frame); +#if JG KTR_LOG(kernentry_fork_ret, lp->lwp_proc->p_pid, lp->lwp_tid); +#else + KTR_LOG_STR(kernentry_fork_ret, "pid=%d, tid=%d", lp->lwp_proc->p_pid, lp->lwp_tid); +#endif } /* diff --git a/sys/platform/pc64/amd64/vm_machdep.c b/sys/platform/pc64/amd64/vm_machdep.c index f9621f3184..a23f3759b9 100644 --- a/sys/platform/pc64/amd64/vm_machdep.c +++ b/sys/platform/pc64/amd64/vm_machdep.c @@ -59,8 +59,8 @@ #include #include #include -#include #include +#include #include #include /* npxthread */ @@ -74,7 +74,7 @@ #include -#include +#include static void cpu_reset_real (void); /* @@ -233,7 +233,25 @@ cpu_set_thread_handler(thread_t td, void (*rfunc)(void), void *func, void *arg) void cpu_lwp_exit(void) { - panic("dummy called in vm_machdep.c: line: %d", __LINE__); + struct thread *td = curthread; + struct pcb *pcb; +#if NNPX > 0 + npxexit(); +#endif /* NNPX */ + KKASSERT(pcb->pcb_ext == NULL); /* Some i386 functionality was dropped */ + if (pcb->pcb_flags & PCB_DBREGS) { + /* + * disable all hardware breakpoints + */ + reset_dbregs(); + pcb->pcb_flags &= ~PCB_DBREGS; + } + td->td_gd->gd_cnt.v_swtch++; + + crit_enter_quick(td); + lwkt_deschedule_self(td); + lwkt_remove_tdallq(td); + cpu_thread_exit(); } /* @@ -248,7 +266,10 @@ cpu_lwp_exit(void) void cpu_thread_exit(void) { - panic("dummy called in vm_machdep.c: line: %d", __LINE__); + curthread->td_switch = cpu_exit_switch; + curthread->td_flags |= TDF_EXITING; + lwkt_switch(); + panic("cpu_thread_exit: lwkt_switch() unexpectedly returned"); } /* @@ -258,7 +279,8 @@ cpu_thread_exit(void) void cpu_proc_wait(struct proc *p) { - panic("dummy called in vm_machdep.c: line: %d", __LINE__); + /* drop per-process resources */ + pmap_dispose_proc(p); } void @@ -339,13 +361,23 @@ cpu_vmspace_alloc(struct vmspace *vm __unused) void cpu_vmspace_free(struct vmspace *vm __unused) { - panic("dummy called in vm_machdep.c: line: %d", __LINE__); } int kvm_access_check(vm_offset_t saddr, vm_offset_t eaddr, int prot) { - panic("dummy called in vm_machdep.c: line: %d", __LINE__); + vm_offset_t addr; + + if (saddr < KvaStart) + return EFAULT; + if (eaddr >= KvaEnd) + return EFAULT; + for (addr = saddr; addr < eaddr; addr += PAGE_SIZE) { + if (pmap_extract(&kernel_pmap, addr) == 0) + return EFAULT; + } + if (!kernacc((caddr_t)saddr, eaddr - saddr, prot)) + return EFAULT; return 0; } diff --git a/sys/platform/pc64/apic/apic_vector.s b/sys/platform/pc64/apic/apic_vector.s index 52e2ff1c68..226d024009 100644 --- a/sys/platform/pc64/apic/apic_vector.s +++ b/sys/platform/pc64/apic/apic_vector.s @@ -42,7 +42,7 @@ #include #include -#include +#include #include "assym.s" diff --git a/sys/platform/pc64/include/globaldata.h b/sys/platform/pc64/include/globaldata.h index 302117fae0..517b03e1be 100644 --- a/sys/platform/pc64/include/globaldata.h +++ b/sys/platform/pc64/include/globaldata.h @@ -112,9 +112,10 @@ struct mdglobaldata { * i386/i386/mp_machdep.c and locore.s. */ struct privatespace { + /* JG TODO: fix comments describing layout */ /* page 0 - data page */ struct mdglobaldata mdglobaldata; - char __filler0[PAGE_SIZE - sizeof(struct mdglobaldata)]; + char __filler0[MDGLOBALDATA_PAD]; /* page 1..4 - CPAGE1,CPAGE2,CPAGE3,PPAGE1 */ char CPAGE1[PAGE_SIZE]; /* SMPpt[1] */ diff --git a/sys/platform/pc64/isa/asc.c b/sys/platform/pc64/isa/asc.c index 50b8299d75..fa68e82618 100644 --- a/sys/platform/pc64/isa/asc.c +++ b/sys/platform/pc64/isa/asc.c @@ -54,8 +54,8 @@ #include -#include -#include +#include +#include #include "ascreg.h" /*** diff --git a/sys/platform/pc64/isa/clock.c b/sys/platform/pc64/isa/clock.c index 6265c31ca0..35247b9d6f 100644 --- a/sys/platform/pc64/isa/clock.c +++ b/sys/platform/pc64/isa/clock.c @@ -84,7 +84,7 @@ #include #include -#include +#include #include #include diff --git a/sys/platform/pc64/isa/intr_machdep.c b/sys/platform/pc64/isa/intr_machdep.c index 9993231095..635878d364 100644 --- a/sys/platform/pc64/isa/intr_machdep.c +++ b/sys/platform/pc64/isa/intr_machdep.c @@ -67,7 +67,7 @@ #include #include -#include +#include #include #if NISA > 0 diff --git a/sys/platform/pc64/isa/npx.c b/sys/platform/pc64/isa/npx.c index 82162bc270..10ac6e1125 100644 --- a/sys/platform/pc64/isa/npx.c +++ b/sys/platform/pc64/isa/npx.c @@ -75,7 +75,7 @@ #ifndef SMP #include #include -#include +#include #endif /* diff --git a/sys/platform/pc64/isa/prof_machdep.c b/sys/platform/pc64/isa/prof_machdep.c index 148cdb99dc..904bc2ec66 100644 --- a/sys/platform/pc64/isa/prof_machdep.c +++ b/sys/platform/pc64/isa/prof_machdep.c @@ -46,7 +46,7 @@ #include -#include +#include #include #ifdef GUPROF diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h index dae0bf4dda..a5b3755f5f 100644 --- a/sys/sys/ktr.h +++ b/sys/sys/ktr.h @@ -65,7 +65,7 @@ #define KTR_AUTO_ENABLE -1 #endif -#define KTR_BUFSIZE 48 +#define KTR_BUFSIZE 192 #define KTR_VERSION 3 #ifndef LOCORE @@ -88,6 +88,7 @@ struct ktr_entry { int32_t ktr_data[KTR_BUFSIZE / sizeof(int32_t)]; }; +void ktr_write_str_entry(struct ktr_info *info, const char *file, int line, const char *format, ...); void ktr_log(struct ktr_info *info, const char *file, int line, ...); void ktr_log_ptr(struct ktr_info *info, const char *file, int line, const void *ptr); void cpu_ktr_caller(struct ktr_entry *ktr); @@ -134,6 +135,11 @@ SYSCTL_DECL(_debug_ktr); format, \ datasize } +#define KTR_LOG_STR(name, format, args...) \ + if (ktr_ ## name ## _enable && \ + (ktr_ ## name ## _mask & *ktr_info_ ## name .kf_master_enable)) \ + ktr_write_str_entry(&ktr_info_ ## name, __FILE__, __LINE__, format, ##args) + #define KTR_LOG(name, args...) \ if (ktr_ ## name ## _enable && \ (ktr_ ## name ## _mask & *ktr_info_ ## name .kf_master_enable)) \ @@ -158,6 +164,7 @@ SYSCTL_DECL(_debug_ktr); #define KTR_LOG(info, args...) #define KTR_LOG_PTR(info, ptr) +#define KTR_LOG_STR(info, format, args...) #endif diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 2944a235ff..100f0d458a 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -61,7 +61,7 @@ #endif #include #include /* For struct klist */ -#include /* For struct klist */ +#include /* For struct sysentvec */ #include #include #include -- 2.41.0