Commit Graph
100 Commits
Author SHA1 Message Date
Alex Smith e453c0f4a7 64-bit printf warning fixes in libroot. 2012-07-28 13:40:09 +01:00
Alex Smith c3b03e5877 64-bit fixes to Hoard. 2012-07-28 13:02:34 +01:00
Alex Smith a3210bbc76 Added x86_64 math functions to libroot.
These have been pulled from glibc 2.10, the last version before a
bunch of changes were made that would have made porting more difficult.
None of this has been tested yet, it is not currently possible to do
so: I'm just trying to get libroot compiling so that I can work on the
runtime loader. I will test them when I am able to.
2012-07-28 12:23:47 +01:00
Alex Smith 04c1e6d017 ASM code fixes for PIC compilation. 2012-07-27 18:16:19 +01:00
Alex Smith 3fde53501d Updated x86_64 fenv.h and added fenv.c. 2012-07-27 15:21:41 +01:00
Alex Smith 5f119ed78f Added x86_64 glue code. 2012-07-27 09:22:54 +01:00
Alex Smith e3ac2588e6 Changed runtime_loader to use elf_* typedefs over Elf32_*.
This means that it will be using ELF64 types on x86_64 rather than
ELF32. The next step for supporting x86_64 is to implement relocations.
2012-07-25 15:05:21 +01:00
Alex Smith ce35b7a68a Fixed broken build for x86. 2012-07-25 15:00:50 +01:00
Alex Smith 6f1f972caf Finished system call handler.
The interrupt and system call handlers now perform all the necessary
kernel entry/exit work, and the system call handler now handles calls
with more than 6 arguments. Debugging and system call tracing hooks
are not yet called, will be added when user debugging gets implemented.
2012-07-25 08:56:47 +01:00
Alex Smith 370ab57d49 Initial userland support for x86_64.
Userland switch is implemented, as is basic system call support (using
SYSCALL/SYSRET). The system call handler is not yet complete: it doesn't
handle more than 6 arguments, and does not perform all the necessary kernel
entry/exit work (neither does the interrupt handler). However, this is
sufficient for runtime_loader to start and print some debug output.
2012-07-23 17:12:12 +01:00
Alex Smith 07c6bd65b8 Format string fixes for TRACE_{THREAD,TEAM}. 2012-07-23 14:20:29 +01:00
Alex Smith fe2e732721 Avoid an unnecessary mov on syscalls with < 4 arguments. 2012-07-23 14:18:54 +01:00
Alex Smith fd9f32c0db Added some libroot bits for x86_64.
Still some parts missing (the glibc bits + fenv.c), plus the TLS
functions are only stubs.
2012-07-22 14:59:42 +01:00
Alex Smith aef19e3c95 Implemented creation and destruction of user translation maps. 2012-07-22 13:07:44 +01:00
Alex Smith 5afce632f3 Demangle symbols in stack traces.
Since the demangle debugger extension now gets loaded when booting
from an image, use it in stack traces. Can't print argument values
like on x86, however, since x86_64 uses registers to pass the first
6 arguments rather than the stack we can't easily get to them.
2012-07-22 12:13:04 +01:00
Alex Smith 700c8d3078 Support building images for x86_64.
Added a temporary Haiku64Image file that gets included instead of
HaikuImage when building for x86_64, which I will add to as I port
stuff. Images currently only include the boot loader, kernel and
a bunch of add-ons.
2012-07-22 11:36:50 +01:00
Alex Smith 1c24ebaa5f 64-bit compilation fixes for BFS, add to x86_64 boot image. 2012-07-22 10:42:35 +01:00
Alex Smith 59ae45c1ab Fixed commpage for x86_64.
Since the commpage is at a kernel address, changed 64-bit paging code
to match x86's behaviour of allowing user-accessible mappings to be
created in the kernel portion of the address space. This is also
required by some drivers.
2012-07-21 16:18:10 +01:00
Alex Smith 195a0f350e Changed argument type of fcntl syscall from uint32 to size_t.
Since this argument may be used to pass pointers, uint32 is not
correct for 64-bit. Effectively no change on 32-bit targets, both
size_t and uint32 are unsigned long there.
2012-07-21 14:33:27 +01:00
Alex Smith 5f6b522746 Merge branch 'master' into x86_64 2012-07-21 14:17:22 +01:00
Alex Smith e6e6f56ccf Include compat/sys/kernel.h rather than "kernel.h".
Using "kernel.h" was pulling in the private kernel.h header instead,
which was causing a build failure on my branch since arch_cpu.h is
C++-only there.
2012-07-21 14:09:08 +01:00
Alex Smith 5234e66d32 Optimized memcpy/memset for x86_64. 2012-07-21 11:55:13 +01:00
Alex Smith 6497f6b1ec Moved the exception handling functions to arch_int.cpp, shared between x86 and x86_64. 2012-07-21 09:11:09 +01:00
Alex Smith 4451c47c64 Compile generic_x86 CPU module for x86_64. 2012-07-21 08:32:07 +01:00
Alex Smith 82694bd124 Merge branch 'master' into x86_64
Conflicts:
	headers/posix/arch/x86_64/arch_setjmp.h
	src/system/kernel/cache/block_cache.cpp
2012-07-20 18:33:46 +01:00
Alex Smith a9fdaec18a Added disk drivers and CD file system modules to the boot image for x86_64.
This adds disk drivers, intel/session partitioning systems, and ISO9660
(+ write/attribute_overlay) modules to the CD/floppy boot image targets
for x86_64. The kernel now detects and mounts the boot CD, and runs up
to attempting to start the boot script.
2012-07-20 17:55:26 +01:00
Alex Smith 7f7e76e461 64-bit compilation fixes for write_overlay and intel partitioning system modules. 2012-07-20 17:53:59 +01:00
Alex Smith 0063d2ba51 Various 64-bit fixes to SCSI and ATA bus managers/drivers.
Mostly compilation fixes, as well as a few 64-bit safety fixes. I've
briefly looked through everything for any obvious issues and fixed
the ones I've found, and it seems like they're working properly, though
there could be some more well hidden ones that I've missed.
2012-07-20 17:47:12 +01:00
Alex Smith d7ec2fa3bf A couple of format string fixes for tracing printfs. 2012-07-20 17:37:37 +01:00
Alex Smith 1b41387b5f Added missing packed attributes on disk_identifier. 2012-07-20 17:14:17 +01:00
Alex Smith 12bd7812dd Ported PCI module to x86_64.
Uses the x86 architecture code, made fixes to printf formats and a
couple of 64-bit fixes. Only potentially intrusive change is that I've
changed PCI.h to use uint32 rather than ulong. I don't see any way
this would cause any issues, though.
2012-07-20 12:00:20 +01:00
Alex Smith 9d4e925cf0 Support x86_64 in config_manager. 2012-07-20 11:56:15 +01:00
Alex Smith 2865db34c8 Compile msi.cpp for x86_64.
Needed to link the PCI module, not enabling it yet though, I'm not
sure whether everything needed for it is in place yet.
2012-07-20 11:53:46 +01:00
Alex Smith 385d69fc01 Made it possible to build kernel modules for x86_64.
Added the necessary build flags for modules, and added a module (dpc)
to the floppy image for x86_64 builds for testing purposes. The module
gets loaded correctly and its code runs without issue. Only non-trivial
addition is the different method for generating kernel.so, this is
explained in the kernel Jamfile.
2012-07-19 17:53:46 +01:00
Alex Smith 0cbce9aa47 A few 64-bit fixes for ELF/module code. 2012-07-19 12:45:17 +01:00
Alex Smith b2cd72d8f3 Implemented arch_debug_call_with_fault_handler for x86_64. 2012-07-14 09:23:48 +01:00
Alex Smith 368f253347 Merge branch 'master' into x86_64 2012-07-14 08:49:14 +01:00
Alex Smith bcb07a319b Implemented the rest of the kernel debugger functions for x86_64.
Merged with the x86 implementations, mostly the same except for a
few differences. GDB stub is currently broken, will investigate
later.
2012-07-13 14:09:09 +01:00
Alex Smith e690e5ab3b Proper fix for GCC 2 compilation error that was fixed earlier, cause pointed out by Ingo. 2012-07-12 17:16:17 +01:00
Alex Smith 8a65fedaaa Merge branch 'master' into x86_64
Conflicts:
	src/system/kernel/arch/x86/arch_debug.cpp
2012-07-12 16:32:12 +01:00
Alex Smith 7dc738b0fb Fixed ordering of registers in arch_debug_gdb_get_registers.
Current code was sending EAX, EBX, ECX, EDX..., GDB (all versions as far
as I can tell) expects EAX, ECX, EDX, EBX... Also added missing FS and GS.
2012-07-12 15:59:50 +01:00
Alex Smith 4ebc6dfa68 Moved some 32-bit specific stuff to the 32 subdirectory. 2012-07-12 14:23:55 +01:00
Alex Smith 6e06fa6f7e Added missing validity check on relocation address. 2012-07-12 14:06:29 +01:00
Alex Smith d38f1301d1 Cleaned up 32-bit descriptors.h. 2012-07-12 13:55:03 +01:00
Alex Smith 5774b5afa4 C++ified remaining C users of arch_cpu.h. 2012-07-12 13:54:18 +01:00
Alex Smith 6ba74ba51c Fixed compilation of the boot loader on GCC 2.
Not sure why but GCC 2 seems to be ignoring the extern "C" in smp.h when
compiling smp_boot_other_cpus() resulting in undefined references. Fixed
by putting extern "C" on the definition too.
2012-07-12 12:21:09 +01:00
Alex Smith 98614a9658 Merge branch 'master' into x86_64 2012-07-12 11:33:39 +01:00
Alex Smith c3f0fd28cd Fixed formatting of output in some debugger commands.
Currently all debugger commands assume 32-bit pointers when formatting their
output. This means that on x86_64 the output is incorrectly formatted. Fixed
this by adding a B_PRINTF_POINTER_WIDTH definition (16 on 64-bit, 8 on
32-bit), and using this to correctly format the output. Not all commands have
been fixed yet, but all VM, slab, VFS, team, thread and image commands should
be correct.
2012-07-12 11:29:33 +01:00
Alex Smith 76a1175dbe Support for SMP on x86_64.
No major changes to the kernel: just compiled in arch_smp.cpp and fixed the
IDT load in arch_cpu_init_percpu to use the correct limit for x86_64 (uses
sizeof(interrupt_descriptor)). In the boot loader, changed smp_boot_other_cpus
to construct a temporary GDT and get the page directory address from CR3, as
what's in kernel_args will be 64-bit stuff and will not work to switch the
CPUs into 32-bit mode in the trampoline code. Refactored 64-bit kernel entry
code to not use the stack after disabling paging, as the secondary CPUs are
given a 32-bit virtual stack address by the SMP trampoline code which will
no longer work.
2012-07-11 18:29:15 +01:00
Alex Smith 97f5a0bd35 Fixed case-sensitive filesystem check. 2012-07-11 17:41:52 +01:00
Alex Smith 659bacac26 Compile arch_real_time_clock.cpp and arch_system_info.cpp for x86_64. 2012-07-11 14:43:44 +01:00
Alex Smith d776fd53f7 Implemented arch_cpu_user_*() for x86_64, based on the x86 versions. 2012-07-11 14:19:19 +01:00
Alex Smith fc644104ac Merge branch 'master' into x86_64 2012-07-11 12:24:47 +01:00
Alex Smith 609b308e64 Return B_NOT_SUPPORTED for shutdown if ACPI is unavailable (no APM on x86_64). 2012-07-11 12:23:18 +01:00
Alex Smith 0962132cc6 Fixed Mac OS X 10.7 as a build platform (for GCC 4).
* Use gcc and g++ rather than cc and c++, as the latter now point to
  clang with recent Xcode versions and compilation of the host tools
  fail for various reasons with it.
* Replace the case-sensitive filesystem check with a more basic one,
  as diskutil no longer supports the behaviour of getting info for the
  volume that any path is on.
* Updated ReadMe with a correct list of prerequisites for OS X.
* GCC 2 builds are still broken due to a strange error that only
  occurs with a GCC 2 built on OS X 10.7
2012-07-10 19:33:39 +01:00
Alex Smith 5670b0a8e4 Moved the 32-bit page fault handler to arch_int.cpp, use it for x86_64.
A proper page fault handler was required for areas that were not locked
into the kernel address space. This enables the boot process to get
up to the point of trying to find the boot volume.
2012-07-09 19:18:09 +01:00
Alex Smith c8049a88a3 Enabled hardware interrupt handler, timers now work and threads are preempted. 2012-07-09 17:42:34 +01:00
Alex Smith b5c9d24abc Implemented threading for x86_64.
* Thread creation and switching is working fine, however threads do not yet
  get interrupted because I've not implemented hardware interrupt handling
  yet (I'll do that next).
* I've made some changes to struct iframe: I've removed the e/r prefixes
  from the member names for both 32/64, so now they're just named ip, ax,
  bp, etc. This makes it easier to write code that works with both 32/64
  without having to deal with different iframe member names.
2012-07-09 16:43:01 +01:00
Alex Smith 85d4a8bc4e Fixed compilation of C code using ELF headers. 2012-07-09 14:35:01 +01:00
Alex Smith 8c5e747190 Don't need to shift the factor in system_time(), just store the already shifted value. 2012-07-09 12:25:49 +01:00
Alex Smith 5e9bb17da7 Renamed remaining i386_* functions to x86_* for consistency. 2012-07-09 12:14:18 +01:00
Alex Smith ee7aba5117 Print symbol information in a stack trace. 2012-07-09 11:54:03 +01:00
Alex Smith 3b802628b8 Support ELF64 in the kernel.
This has been done by adding typedefs in elf_common.h to the correct ELF
structures for the architecture, and changing all Elf32_* uses to those
types. I don't know whether image loading works as I cannot test it yet,
there may be some 64-bit safety issues around. However, symbol lookup for
the kernel is working correctly.
2012-07-09 11:11:38 +01:00
Alex Smith bc3093488f Changes suggested by Ingo: style fix, and a system_time optimization. 2012-07-09 09:03:11 +01:00
Alex Smith 93cba1da96 Fixed a bug resulting from a mistake in the boot 64-bit paging setup.
This was an interesting bug to find. Was getting spurious triple faults
in the slab allocator. The problem was that the boot paging setup code
was mapping all page tables it created into the virtual address space,
but in the kernel no areas were being created to cover them, so during
arch_vm_init_end() the pages for them ended up being freed and then
overwritten later on. Fixed by unmapping page tables after populating
them in long_mmu_init().
2012-07-08 15:03:23 +01:00
Alex Smith cc248cf2b3 A couple of bug fixes.
* mmu_get_virtual_mapping() should check that the page directory entry is
  present rather than assuming there's a page table there. This was resulting
  in some invalid mappings being created in the 64-bit virtual address space.
* arch_vm_init_end() should clear from KERNEL_LOAD_BASE to virtual_end, not
  from KERNEL_BASE. On x86_64 this was causing it to loop through ~512GB of
  address space, which obviously was taking quite a while.
2012-07-08 11:56:06 +01:00
Alex Smith 5c7d52183c Implemented system_time() for x86_64.
* Uses 64-bit multiplication, special handling for CPUs clocked < 1 GHz
  in system_time_nsecs() not required like on x86.
* Tested against a straight conversion of the x86 version, noticably
  faster with a large number of system_time() calls.
2012-07-08 10:16:44 +01:00
Alex Smith 7444a55ce5 Merge branch 'master' into x86_64 2012-07-06 15:55:59 +01:00
Alex Smith c15176264b Compile APIC and timer code for x86_64, and create an area for the IDT. 2012-07-06 15:24:02 +01:00
Alex Smith 15feb60325 A few improvements suggested by Ingo. 2012-07-06 14:34:50 +01:00
Alex Smith 84bf29f97b Compile in arch_platform.cpp for x86_64. The apm_init call is disabled for x86_64, APM is 32-bit only. 2012-07-06 14:17:48 +01:00
Alex Smith ab7726a2c4 Temporary fix for create_preloaded_image_areas. Will be replaced with a typedef later on. 2012-07-06 14:04:07 +01:00
Alex Smith e276cc0457 Finished implementation of x86_64 paging.
* vm_init now runs up until create_preloaded_image_areas(), which needs
  fixing to handle ELF64.
* Not completely tested. I know Map(), Unmap() and Query() work fine, the
  other methods have not been tested as the kernel doesn't boot far enough
  for any of them to be called yet. As far as I know they're correct, though.
* Not yet implemented the destructor for X86VMTranslationMap64Bit or Init()
  for a user address space.
2012-07-06 12:52:35 +01:00
Alex Smith 11d35d1b9b Fixed tracing printf formats in VM code. 2012-07-05 20:17:31 +01:00
Alex Smith 1671cfdf2c Improved stack tracer, traces over iframes. 2012-07-05 16:11:11 +01:00
Alex Smith 898b29e362 Added temporary stack trace function to x86_64.
Will be merged with the x86 one later on. Requires -fno-omit-frame-pointer on
the kernel build flags, GCC defaults to not generating stack frames on x86_64.
2012-07-05 15:35:43 +01:00
Alex Smith 0da10c8b51 Some fixes to the long mode switch code.
* Wasn't storing the fixed virtual address of the PML4 in kernel_args.
* After switching to long mode, reload GDTR with the virtual address of
  the GDT. This was working fine until now because the physical address
  was identity mapped, but broke as soon as I removed the identity
  mapping.
2012-07-05 13:55:59 +01:00
Alex Smith 2f36ef5afe Fixed the x86_64 setjmp implementation.
* typedef for jmp_buf was using int where it should be long.
* setjmp was clearing the buffer pointer rather than the signal mask before
  calling sigsetjmp.
* KDL now works without crashing on x86_64.
2012-07-05 13:52:36 +01:00
Alex Smith 78d482e3b8 Style fixes. 2012-07-05 09:10:50 +01:00
Alex Smith d687d8ac70 Implementation of VMPhysicalPageMapper for x86_64 using the permanent physical memory mapping. 2012-07-04 19:57:48 +01:00
Alex Smith 40aeaeb907 Should enable CR4.PGE while switching to the kernel. 2012-07-04 18:39:23 +01:00
Alex Smith a8f85e6e48 Removed accidently left in debug message. 2012-07-04 18:33:21 +01:00
Alex Smith e70dd7e0af Map all physical memory in the long mode paging setup.
Since x86_64 has such a large virtual address space all available physical
memory can be mapped in to it. The physical page mapper implementation for
x86_64 will use this mapping. Also changed the mapping code to map kernel
pages with the global flag.
2012-07-04 18:28:50 +01:00
Alex Smith 950b24e32d Begun work on VMTranslationMap implementation for x86_64.
* Added empty source files for all the 64-bit paging method code, and a
  stub implementation of X86PagingMethod64Bit.
* arch_vm_translation_map.cpp has been modified to use X86PagingMethod64Bit
  on x86_64.
2012-07-04 17:08:44 +01:00
Alex Smith 4988ca58a0 Build arch_vm.cpp for x86_64. No changes required except for temporarily disabling bios_init call. 2012-07-04 14:55:11 +01:00
Alex Smith 428b9e758c Check whether gX86PagingMethod is NULL in arch_vm_translation_map_is_kernel_page_accessible.
This means that the kernel debugger won't cause a recursive panic if a
panic occurs before vm_init().
2012-07-04 14:23:35 +01:00
Alex Smith 4304bb9894 Added arch_cpu.cpp to the x86_64 build.
* Some things are currently ifndef'd out completely for x86_64 because
  they aren't implemented, there's a few other ifdef's to handle x86_64
  differences but most of the code works unchanged.
* Renamed some i386_* functions to x86_*.
* Added a temporary method for setting the current thread on x86_64
  (a global variable, not SMP safe). This will be changed to be done
  via the GS segment but I've not implemented that yet.
2012-07-04 14:06:46 +01:00
Alex Smith 4e8fbfb2d1 x86_{read,write}_cr{0,4} can just be implemented as macros, put an x86_ prefix on the other read/write macros for consistency. 2012-07-03 20:55:36 +01:00
Alex Smith cbfe5fcd17 Removed redundant x86 sources/headers. 2012-07-03 17:38:18 +01:00
Alex Smith c005e747ef Removed the x86_64 headers/source directories, now all merged with x86. 2012-07-03 11:17:56 +01:00
Alex Smith 4f419b518f Merged in the x86_64 exception handling.
I've split the 32-bit dependent IDT setup code and ASM interrupt handlers to
the 32 subdirectory, arch_int.cpp now contains only the generic hardware
interrupt handling code.
2012-07-03 11:13:51 +01:00
Alex Smith 22fe9b20f5 Merge branch 'master' into x86_64 2012-07-03 08:46:52 +01:00
Alex Smith 90907c35ac Moved ELF64 relocation functions to x86 arch_elf.cpp. 2012-07-03 08:45:35 +01:00
Alex Smith 020a25ce46 Fixed x86_64 kernel compilation.
For now I've just put all the stub functions that are needed to link the
kernel into a file called stubs.cpp. I've not yet moved across the interrupt
handling code or the ELF64 relocation code to the x86 directory. Once those
have been moved I can get rid of the x86_64 headers/source directories.
2012-07-02 20:56:27 +01:00
Alex Smith 0897e314b7 Merged x86_64 headers into x86 headers.
Not many changes seeing as there's not much x86_64 stuff done yet. Small
differences are handled with ifdefs, large differences (descriptors.h,
struct iframe) have separate headers under arch/x86/32 and arch/x86/64.
2012-07-02 18:47:06 +01:00
Alex Smith da80a0500c Preparation for merge of x86 and x86_64 kernel sources.
Since x86 and x86_64 share a lot of common code, x86_64 kernel sources/headers
are going to reside under headers/private/kernel/arch/x86 and
src/system/kernel/arch/x86 along with the existing x86 code. This commit
changes the build system to handle this. A new variable, TARGET_KERNEL_ARCH,
has been added. This is the name of the kernel/boot architecture directory
name, set to x86 on both x86 and x86_64. This is now used in all places where
TARGET_ARCH was used to get to kernel arch sources/headers (I've changed
everything necessary as far as I can tell). Kernel won't build for x86_64
at the moment as the sources have not been merged, loader does.
2012-07-02 14:07:49 +01:00
Alex Smith 4f78437c0d Style fix. 2012-07-02 10:13:37 +01:00
Alex Smith 120585d549 Merge branch 'master' into x86_64 2012-07-02 09:39:42 +01:00
Alex Smith 294711f98c Changed {,u}int64 to be long rather than long long on x86_64. 2012-06-28 12:36:45 +01:00
Alex Smith 0705884ac4 Style fixes. 2012-06-27 15:48:39 +01:00