Commit graph

185 commits

Author SHA1 Message Date
Tomas Hruby 13a0d5fa5e SMP - Cpu local variables
- most global variables carry information which is specific to the
  local CPU and each CPU must have its own copy

- cpu local variable must be declared in cpulocal.h between
  DECLARE_CPULOCAL_START and DECLARE_CPULOCAL_END markers using
  DECLARE_CPULOCAL macro

- to access the cpu local data the provided macros must be used

	get_cpu_var(cpu, name)
	get_cpu_var_ptr(cpu, name)

	get_cpulocal_var(name)
	get_cpulocal_var_ptr(name)

- using this macros makes future changes in the implementation
  possible

- switching to ELF will make the declaration of cpu local data much
  simpler, e.g.

  CPULOCAL int blah;

  anywhere in the kernel source code
2010-09-15 14:09:46 +00:00
Tomas Hruby ce4fd0c0fb Enable paging - some more code reshuffling 2010-09-15 14:09:41 +00:00
Tomas Hruby 6c3b981cd6 arch proto.h renamed to arch_proto.h
- the file moved to the arch include dir
2010-09-15 14:09:36 +00:00
Tomas Hruby e6ebac015d APIC mode uses IO APICs
- kernel turns on IO APICs if no_apic is _not_ set or is equal 0

- pci driver must use the acpi driver to setup IRQ routing otherwise
  the system cannot work correctly except systems like KVM that use
  only legacy (E)ISA IRQs 0-15
2010-09-07 07:18:11 +00:00
Tomas Hruby 2440ffae49 Kernel exports DSDP and apic_enabled in machine structure
- kernel exports DSDP (the root pointer where ACPI parsing starts) and
  apic_enabled in the machine structure.

- ACPI driver uses DSDP to locate ACPI in memory. acpi_enabled tell
  PCI driver to query ACPI for IRQ routing information.
2010-09-02 15:43:56 +00:00
Tomas Hruby 45badf4c05 ACPI in kernel
- the ability for kernel to use ACPI tables to detect IO APICs. It is
  the bare minimum the kernel needs to know about ACPI tables.

- it will be used to find out about processors as the MPS tables are
  deprecated by ACPI and not all vendorsprovide them.
2010-09-02 15:43:51 +00:00
Erik van der Kouwe 1f2054c89c Shutdown changes for multiboot: CTRL-ALT-DEL resets, panic halts 2010-08-30 19:01:58 +00:00
Arun Thomas 9a21d1a2fd Macros for symbols used in both ASM and C
-The macros take care of prepending the leading underscore when
 necessary.
2010-08-17 16:44:07 +00:00
Tomas Hruby f7ef192c02 Fixed warning noreturn function returns in arch_system.c 2010-08-06 12:48:26 +00:00
Tomas Hruby 58654acf08 both ack and gcc can compile klib16.S 2010-08-06 12:46:44 +00:00
Tomas Hruby ac9a7f47bd Missing prototype in pre_init.c
- gcc does not like it
2010-08-06 12:26:26 +00:00
Erik van der Kouwe 25397ef756 Deal all shutdown cases with multiboot as either reset or poweroff depending on their type (contributed by Feiran 'Fam' Zheng) 2010-08-02 14:41:45 +00:00
Erik van der Kouwe ebec792700 Display fallback message in case poweroff fails (contributed by Feiran 'Fam' Zheng) 2010-08-02 14:40:26 +00:00
Erik van der Kouwe df0ba02a38 Multiboot support (contributed by Feiran "Fam" Zheng);
keep in mind that GRUB needs to be patched to read MFS for now;
use /boot/image_latest to boot the last compiled image in GRUB
2010-07-23 14:24:34 +00:00
Erik van der Kouwe f389ad2655 Move sensitive instructions from libc into kernel 2010-07-23 07:12:47 +00:00
Cristiano Giuffrida 03bb1e5750 Don't panic so easily on unexpected pagefault. 2010-07-20 23:51:34 +00:00
Cristiano Giuffrida 0d984b36ef Get rid of static spare pages after VM startup. 2010-07-20 21:59:27 +00:00
Ben Gras c0074d3aa9 kernel: fix case of EAX getting clobbered after sigreturn. 2010-07-20 17:10:09 +00:00
Ben Gras e0701109ca kernel: make loading kernel in 2nd chunk of memory (at 1MB) the default.
(indicated by flags hardcoded in kernel that the boot monitor
interprets.)
2010-07-19 16:33:49 +00:00
Ben Gras f6f814cb02 include, kernel: minor fixes to make compiling and linking work with clang.
(fixing warnings)
2010-07-06 11:59:19 +00:00
Ben Gras 42399159da kernel: these asserts from r7657 are not reasonable
will fire if copy needs more than one try, which is legit.
2010-07-05 17:45:16 +00:00
Ben Gras 545054c608 kernel: use MF_KCALL_RESUME instead of RTS_VMREQUEST for memcopy retry.
solves tracker item 499, submitted by Roman Ignatov.
2010-07-04 23:09:24 +00:00
Tomas Hruby 7920d48156 FPU cleanup
- last reference to MF_USED_FPU removed

- proc_used_fpu() used to test for MF_FPU_INITIALIZED
2010-07-01 12:23:25 +00:00
Arun Thomas c0c8d25799 Rename mkfiles from minix.*.mk to bsd.*.mk
Makes things easier for pkgsrc
2010-06-25 18:29:09 +00:00
Ben Gras b3a0a2d86f kernel: don't initialize catch_pagefaults at the extern declaration. 2010-06-24 12:23:23 +00:00
Tomas Hruby 360de619c0 No linear addresses in message delivery
- removes p_delivermsg_lin item from the process structure and code
  related to it

- as the send part, the receive does not need to use the
  PHYS_COPY_CATCH() and umap_local() couple.  

- The address space of the target process is installed before
  delivermsg() is called.

- unlike the linear address, the virtual address does not change when
  paging is turned on nor after fork().
2010-06-11 08:16:10 +00:00
Ben Gras a6e357da22 kernel: fix assert condition after a caught in-kernel pagefault 2010-06-09 10:59:57 +00:00
Kees van Reeuwijk 826b9590f2 More endpoint_t correctness.
More const correctness.
Other code cleanup.
2010-06-08 14:09:18 +00:00
Ben Gras a09a8d4f3e kernel: fix for vm_init that triggered assert(ptproc == newptproc)
- zero cr3 in vm_init() to avoid switch_address_space() not doing anything.

 - add vm_stop() to disable paging on shutdown.
2010-06-07 22:21:45 +00:00
Tomas Hruby cbc9586c13 Lazy FPU
- FPU context is stored only if conflict between 2 FPU users or while
  exporting context of a process to userspace while it is the active
  user of FPU

- FPU has its owner (fpu_owner) which points to the process whose
  state is currently loaded in FPU

- the FPU exception is only turned on when scheduling a process which
  is not the owner of FPU

- FPU state is restored for the process that generated the FPU
  exception. This process runs immediately without letting scheduler
  to pick a new process to resolve the FPU conflict asap, to minimize
  the FPU thrashing and FPU exception hadler execution

- faster all non-FPU-exception kernel entries as FPU state is not
  checked nor saved

- removed MF_USED_FPU flag, only MF_FPU_INITIALIZED remains to signal
  that a process has used FPU in the past
2010-06-07 07:43:17 +00:00
Ben Gras 2f892aca91 kernel fpu context switching: fix race condition
There seems to have been a broken assumption in the fpu context
restoring code.  It restores the context of the running process, without
guarantee that the current process is the one that will be scheduled.
This caused fpu saving for a different process to be triggered without
fpu hardware being enabled, causing an fpu exception in the kernel. This
practically only shows up with DEBUG_RACE on. Fix my thruby+me.

The fix
 . is to only set the fpu-in-use-by-this-process flag in the
   exception handler, and then take care of fpu restoring when
   actually returning to userspace

And the patch
 . translates fpu saving and restoring to c in arch_system.c,
   getting rid of a juicy chunk of assembly
 . makes osfxsr_feature private to arch_system.c
 . removes most of the arch dependent code from do_sigsend
2010-06-03 11:32:22 +00:00
Kees van Reeuwijk ed0b81c25c Removed some unused variables and functions. 2010-06-02 19:41:38 +00:00
Tomas Hruby 463be393c2 Gracefull crash if FPU exception in kernel 2010-06-02 13:59:55 +00:00
Tomas Hruby 7bfa47476c Fixed stack trace if panic in stop_context() 2010-06-02 08:53:49 +00:00
Arun Thomas 007104d60e GCC build fixes/updates
-Set stack sizes for boot image processes
-Increase RS stack size
-Reduce ramdisk size
-HARDWARE task should use kernel stack
-Minor asm tweaks for leading underscores
2010-05-26 18:45:55 +00:00
Tomas Hruby 24764ff47a Fixed ms-based scheduling for legacy timer 2010-05-26 08:20:29 +00:00
Tomas Hruby 451a6890d6 scheduling - time quantum in miliseconds
- Currently the cpu time quantum is timer-ticks based. Thus the
  remaining quantum is decreased only if the processes is interrupted
  by a timer tick. As processes block a lot this typically does not
  happen for normal user processes. Also the quantum depends on the
  frequency of the timer.

- This change makes the quantum miliseconds based. Internally the
  miliseconds are translated into cpu cycles. Everytime userspace
  execution is interrupted by kernel the cycles just consumed by the
  current process are deducted from the remaining quantum.

- It makes the quantum system timer frequency independent.

- The boot processes quantum is loosely derived from the tick-based
  quantas and 60Hz timer and subject to future change

- the 64bit arithmetics is a little ugly, will be changes once we have
  compiler support for 64bit integers (soon)
2010-05-25 08:06:14 +00:00
Kees van Reeuwijk ac14a989b3 Fixed some inconsistent strict typing declarations.
Better strict typing.
2010-05-25 07:23:24 +00:00
Erik van der Kouwe 1f11a57141 Oops, last commit included more than was intended 2010-05-20 08:07:47 +00:00
Erik van der Kouwe 5f15ec05b2 More system processes, this was not enough for the release script to run on some configurations 2010-05-20 08:05:07 +00:00
Arun Thomas b0159ad168 Buildsystem changes for GCC
-Makefile updates
-Update mkdep
-Build fixes/warning cleanups for some programs
-Restore leading underscores on global syms in kernel asm files
-Increase ramdisk size
2010-05-19 13:24:15 +00:00
Ben Gras 6d0e53c2ca use oxpcie only if enabled to avoid baud bottleneck of uart. 2010-05-19 10:18:46 +00:00
Ben Gras 9ba760e603 kernel: oxpcie serial card support.
ask to map in oxpcie i/o memory and support serial i/o for it in the
kernel. set oxpcie=<address> in boot monitor (retrieve address using
pci_debug=1 output). (no sanity checking is done on the address
currently.) disabled by default.

The change also contains some other minor cleanup (a new serial.h to set
register info common to UART and the OXPCIe card, in-kernel memory
mapping a little more structured and env_get() to get sysenv variables
without knowing about the params_buffer).
2010-05-19 10:00:02 +00:00
Tomas Hruby b90c2d7026 rename of mode/context switching functions
- this patch only renames schedcheck() to switch_to_user(),
  cycles_accounting_stop() to context_stop() and restart() to
  +restore_user_context()

- the motivation is that since the introduction of schedcheck() it has
  been abused for many things. It deserves a better name.  It should
  express the fact that from the moment we call the function we are in
  the process of switching to user.

- cycles_accounting_stop() was originally a single purpose function.
  As this function is called at were convenient places it is used in
  for other things too, e.g. (un)locking the kernel. Thus it deserves
  a better name too.

- using the old name, restart() does not call schedcheck(), however
  calls to restart are replaced by calls to schedcheck()
  [switch_to_user] and it calls restart() [restore_user_context]
2010-05-18 13:00:39 +00:00
Ben Gras bfc9c5c3a8 kernel: small ammendment to pagefault-in-kernel panic 2010-05-12 08:56:11 +00:00
Ben Gras c5c25e7abc kernel/vm: change pde table info from single buffer to explicit per-process.
makes code in kernel more readable, and allows better sanity checking on
using the pde info.
2010-05-12 08:31:05 +00:00
Ben Gras 7c5e1d1b29 kernel - don't print info about scheduled process if pagefault happened in kernel. 2010-05-11 15:14:10 +00:00
Tomas Hruby 6e25ad8b0a Use of all NIL_* defines converted to NULL 2010-05-10 13:26:00 +00:00
Tomas Hruby 57a88ce708 debugging - printing processes on serial
- this patch moves the former printslot() from arch_system.c to
  debug.c and reimplements it slightly. The output is not changed,
  however, the process information is printed in a separate function
  print_proc() in debug.c as such a function is also handy in other
  situations and should be publicly available when debugging.
2010-05-03 17:37:18 +00:00
Ben Gras 50335291ae kernel: fpu_init: only enable OSXMMEXCPT in CR4 on at least SSE1 machines.
Found and debugged by totalinux at yandex.ru and Evgeniy Ivanov, thanks!
2010-04-28 13:51:02 +00:00