Peter Wemm [Thu, 1 May 2003 01:05:25 +0000 (01:05 +0000)]
Commit MD parts of a loosely functional AMD64 port. This is based on
a heavily stripped down FreeBSD/i386 (brutally stripped down actually) to
attempt to get a stable base to start from. There is a lot missing still.
Worth noting:
- The kernel runs at 1GB in order to cheat with the pmap code. pmap uses
a variation of the PAE code in order to avoid having to worry about 4
levels of page tables yet.
- It boots in 64 bit "long mode" with a tiny trampoline embedded in the
i386 loader. This simplifies locore.s greatly.
- There are still quite a few fragments of i386-specific code that have
not been translated yet, and some that I cheated and wrote dumb C
versions of (bcopy etc).
- It has both int 0x80 for syscalls (but using registers for argument
passing, as is native on the amd64 ABI), and the 'syscall' instruction
for syscalls. int 0x80 preserves all registers, 'syscall' does not.
- I have tried to minimize looking at the NetBSD code, except in a couple
of places (eg: to find which register they use to replace the trashed
%rcx register in the syscall instruction). As a result, there is not a
lot of similarity. I did look at NetBSD a few times while debugging to
get some ideas about what I might have done wrong in my first attempt.
Peter Wemm [Thu, 1 May 2003 00:10:38 +0000 (00:10 +0000)]
KPT_MIN_ADDRESS and KPT_MAX_ADDRESS are not used anywhere. And if they
were, they are not safe to use outside of the kernel since these values
can change at kernel compile time - ie: we do not want them compiled into
userland binaries.
Peter Wemm [Wed, 30 Apr 2003 22:51:59 +0000 (22:51 +0000)]
Repocopy from x86_64/... to amd64/...
Rename visible x86_64 references to amd64.
Kill MID_MACHINE, its a.out specific, the only platform that supports it
is i386. All of the other platforms should remove it too.
Peter Wemm [Wed, 30 Apr 2003 21:41:41 +0000 (21:41 +0000)]
Create a 'legacy' node for AMD64 as well as i386. While we'll never
have to use it since all AMD64 machines are supposed to have acpi etc,
I'm using it during development so I can avoid the acpi code for now.
Yes, this is cheating.
Peter Wemm [Wed, 30 Apr 2003 19:27:07 +0000 (19:27 +0000)]
Update for AMD64. repocopied from i386-elf/crt1.c. Deal with regparm
argument passing rather than stack based args. The kernel passes the
base of the argument/env vector in %rdi (arg1).
Peter Wemm [Wed, 30 Apr 2003 18:16:33 +0000 (18:16 +0000)]
Update for AMD64 after repocopy from i386/sys/*. This means:
- strip out the nasty PIC_PROLOGUE/EPILOGUE stuff, since we dont have
to lose a register in PIC mode anymore (we use %rip-relative addressing).
- update for C register argument passing conventions.
- convert 32 bit to 64 bit register sizes etc.
Peter Wemm [Wed, 30 Apr 2003 18:13:13 +0000 (18:13 +0000)]
Update for AMD64 (repocopied from i386/sys/Ovfork.S - why is it O?)
Depend on %rsi being preserved across the "syscall"-style syscall and strip
out the PIC stuff (this cpu has full PC-relative addressing, at last!)
Peter Wemm [Wed, 30 Apr 2003 18:09:33 +0000 (18:09 +0000)]
Update for AMD64 contexts. Note that this still has some x87-style FPU
instructions here, these may need to be updated for SSE.
(Repocopied from i386/gen)
Peter Wemm [Wed, 30 Apr 2003 18:07:23 +0000 (18:07 +0000)]
Update for AMD64 (repocopied from i386/net). We can depend on having
the bswap instruction (yay!). Update for register parameter passing
instead of i386 style stack based param passing.
Peter Wemm [Wed, 30 Apr 2003 18:06:14 +0000 (18:06 +0000)]
Update for AMD64-style syscalls. Repocopied from i386/SYS.h.
Note that the syscall instruction clobbers %rcx, which is inconvenient
because it is the fourth syscall argument, so we use %r10 (another scratch
register) for the 4th syscall arg instead (I picked %r10 to be the same as
NetBSD). int 0x80 is still possible though, and it uses %rcx as usual.
Note that the syscall style syscall does *NOT* preserve all the registers,
unlike int 0x80. We do not preserve the scratch registers except for
%rdi and %rsi. int 0x80 does preserve everything but the return values.
David E. O'Brien [Wed, 30 Apr 2003 16:21:03 +0000 (16:21 +0000)]
Floating point libc functions traditionally written in ASM.
AMD64 does away with the x87 in 64-bit long mode, so we have to play the
SSE/SSE2 game now.
Mark Murray [Wed, 30 Apr 2003 12:57:40 +0000 (12:57 +0000)]
Fix some easy, global, lint warnings. In most cases, this means
making some local variables static. In a couple of cases, this means
removing an unused variable.
Mark Murray [Wed, 30 Apr 2003 12:23:58 +0000 (12:23 +0000)]
Warns fixing. Protect against inappropriate linting, and mark
GCC-specific assemble code as such (in #ifdefs). Fix an easy
static variable warning while I'm here.
Mark Murray [Wed, 30 Apr 2003 11:17:33 +0000 (11:17 +0000)]
Fix "make world" for the WANT_LINT case. The various build tools
must not try to lint(1) stuff at *-tools time; keep the linting
for the actual build (which comes later).
Mike Makonnen [Wed, 30 Apr 2003 10:25:57 +0000 (10:25 +0000)]
Backout my changes in rev. 1.32 and 1.33. There is some code that depends
on the previous behaviour. This also brings strptime(3) behaviour back in line
with the other BSDs.
Mike Makonnen [Wed, 30 Apr 2003 07:12:09 +0000 (07:12 +0000)]
This script should require mountcritremote, since that is the last
script at which a filesystem will be mounted in FreeBSD. Without this
the script was being inserted later in the boot than necessary.
o Don't announce that the timer is good when in fact it isn't timing
at all (ie reads yield constant values). Display the width as the
difference between max and min so that constant timers have width
zero.
o Get the address of the timer from the XPmTmrBlk field instead of
the V1_PmTmrBlk field. The former is a generic address and can
specify a memory mapped I/O address. Remove <machine/bus_pio.h>
to account for this. The timer is now properly configured on
machines with ACPI v2 tables, whether PIO or MEMIO. Note that
the acpica code converts v1 tables into v2 tables so the address
is always present in XPmTmrBlk.
o Replace the TIMER_READ macro with a call to the read_counter()
function and add a barrier to make sure that we observe proper
ordering of the reads.
Mike Makonnen [Wed, 30 Apr 2003 03:03:47 +0000 (03:03 +0000)]
This particular debugging statement is very verbose, making the rest
of the debug output hard to follow. Comment it out. It's commented out
in NetBSD's version as well.
Mike Makonnen [Wed, 30 Apr 2003 02:19:38 +0000 (02:19 +0000)]
Running the script with restart or manually stopping and starting
it doesn't work because the start_cmd doesn't enable ipfilter if
it is currently disabled.
Warner Losh [Wed, 30 Apr 2003 01:54:38 +0000 (01:54 +0000)]
Get rid of the redundant 'gone' field, and overload suspend instead.
Check for suspend before the device polling, rather than after it.
Check to see if the current thread owns the lock in ioctl and return
EBUSY if it does.
This advances the locking to the point that I can eject my fxp card 10
times in a row, but I agree with Jeff Hsu that we need to get the
network layer locking finished before chasing more of the races here
(actually, he doesn't think this set is worth it even). There's a
number of races between FXP_LOCK in detach and all other users of
FXP_LOCK, and this gets back to the 'device with sleepers being
forcibly detached' problem as well...
Add support to CAM for devices with more than 2^32 blocks. (2TB if you're
using 512 byte blocks).
cam_ccb.h: Bump up volume_size and cylinders in ccb_calc_geometry to
64 bits and 32 bits respectively, so we can hold larger
device sizes. cylinders would overflow at about 500GB.
Bump CAM_VERSION for this change. Note that this will
require a recompile of all applications that talk to the
pass(4) driver.
scsi_all.c: Add descriptions for READ/WRITE(16), update READ/WRITE(12)
descriptions, add descriptions for SERVICE ACTION IN/OUT.
Add a new function, scsi_read_capacity_16(), that issues
the read capacity service action. (Necessary for arrays
larger than 2^32 sectors.) Update scsi_read_write() to use
a 64 bit LBA and issue READ(16) or WRITE(16) if necessary.
NOTE the API change. This should be largely transparnet
to most userland applications at compile time, but will
break binary compatibility. The CAM_VERSION bump, above,
also serves the purpose of forcing a recompile for any
applications that talk to CAM.
scsi_all.h: Add 16 byte READ/WRITE structures, structures for 16 byte
READ CAPACITY/SERVICE ACTION IN. Add scsi_u64to8b() and
scsi_8btou64.
scsi_da.c: The da(4) driver probe now has two stages for devices
larger than 2TB. If a standard READ CAPACITY(10) returns
0xffffffff, we issue the 16 byte version of read capacity
to determine the true array capacity. We also do the same
thing in daopen() -- use the 16 byte read capacity if the
device is large enough.
The sysctl/loader code has also been updated to accept
16 bytes as a minimum command size.
Jacques Vidrine [Tue, 29 Apr 2003 21:13:50 +0000 (21:13 +0000)]
`Hide' strlcpy and strlcat (using the namespace.h / __weak_reference
technique) so that we don't wind up calling into an application's
version if the application defines them.
Inspired by: qpopper's interfering and buggy version of strlcpy
Fix an obscure fencepost error in GBDE's sector mapping code:
For certain combinations of sectorsize, mediasize and random numbers
(used to define the mapping), a multisector read or write would ignore
some subset of the sectors past the first sector in the request because
those sectors would be mapped past the end of the parent device, and
normal "end of media" truncation would zap that part of the request.
Rev 1.19+1.20 of g_bde_work.c added the check which should have alerted
me to this happening. This commit maps the request correctly and
adds KASSERTS to make sure things stay inside the parent device.
This does not change the on-disk layout of GBDE, there is no need to
backup/restore.