Skip to content
Snippets Groups Projects
  1. Jan 10, 2014
    • Takuya ASADA's avatar
      pci: Fix offsets in *_pci_config_* · f0aa8143
      Takuya ASADA authored
      On VMware, pci_readw(PCI_CFG_DEVICE_ID) returns the *vendor ID*.
      pci_readw(PCI_CFG_VENDOR_ID) returns vendor ID as well.
      
      Compare to FreeBSD implementation of read/write PCI config space,
      FreeBSD masks lower bit of offset when write to PCI_CONFIG_ADDRESS, and
      adds lower bit of offset to PCI_CONFIG_DATA.
      
      http://fxr.watson.org/fxr/source/amd64/pci/pci_cfgreg.c#L206
      
      
      
      This patch changes accessing method in OSv to the FreeBSD way.  Tested
      on QEMU/KVM and VMware.
      
      Reviewed-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
      Signed-off-by: default avatarTakuya ASADA <syuu@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      f0aa8143
    • Nadav Har'El's avatar
      clock: add monotonic uptime clock · 8dffa912
      Nadav Har'El authored
      
      This patch starts to solve both issue #142 ("Support MONOTONIC_CLOCK")
      and issue #81 (use <chrono> for time).
      
      First, it adds an uptime() function to the "clock" interface, and
      implements it for kvm/xen/hpet by returning the system time from which
      we subtract the system time at boot (but not adding any correction
      for wallclock).
      
      Second, it adds a new std::chrono-based interface to this clock, in
      a new header file <osv/clock.hh>. Instead of the old-style
      clock::get()->uptime(), one should prefer osv::clock::uptime::now().
      This returns a std::chrono::time_point which is type-safe, in the
      sense that: 1. It knows what its epoch is (i.e., that it belongs to
      osv::clock::uptime), and 2. It knows what its units are (nanoseconds).
      This allows the compiler to prevent a user from confusing measurements
      from this clock with those from other clocks, or making mistakes in
      its units.
      
      Third, this patch implements clock_gettime(MONOTONIC_CLOCK), using
      the new osv::clock::uptime::now().
      
      Note that though the new osv::clock::uptime is almost identical to
      std::chrono::steady_clock, they should not be confused. The former is
      actually OSv's implementation of the latter: steady_clock is implemented
      by the C++11 standard library using the Posix clock_gettime, and that
      is implemented (in this patch) using osv::clock::uptime.
      
      With this patch, we're *not* done with either issues #142 or #81.
      For issue #142, i.e., for supporting MONOTONIC_CLOCK in timerfd, we
      need OSv's timers to work on uptime(), not on clock::get()->time().
      For issue #81, we should add a osv::clock::wall type too (similar to
      what clock::get()->time() does today, but more correctly), and use either
      osv::clock::wall or osv::clock::uptime everywhere that
      clock::get()->time() is currently used in the code.
      clock::get()->time() should be removed.
      
      Reviewed-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      8dffa912
  2. Jan 07, 2014
    • Nadav Har'El's avatar
      Exile spinlock to a separate file · 8fcad509
      Nadav Har'El authored
      
      In very early OSv history, the spinlock was used in the mutex's
      implementation so it made sense to put it in mutex.cc and mutex.h.
      
      But now that the spinlock is all that's left in mutex.cc (the real mutex
      is in lfmutex.cc), rename this file spinlock.cc. Also, move the spinlock
      definitions from <osv/mutex.h> to a new <osv/spinlock.h>, so if someone
      wants to make the grave mistake of using a spinlock - they will at least
      need to explicitly include this header file.
      
      Currently, the only remaining user of the spinlock is the console.
      Using a spinlock (and not a mutex) in the console allows printing debug
      messages while preemption is disabled. Arguably, this use-case is no
      longer important (we have tracepoints), so in the future we can consider
      dropping the spinlock completely.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
      8fcad509
  3. Jan 01, 2014
    • Nadav Har'El's avatar
      file: reduce boiler-plate code in special files · 9478a14d
      Nadav Har'El authored
      
      Each implementation of "struct file" needs to implement 8 different file
      operations. Most special file implementations, such as pipe, socketpair,
      epoll and timerfd, don't support many of these operations. We had in
      unsupported.h functions that can be reused for the unsupported operation,
      but this resulted in a lot of ugly boiler-plate code.
      
      Instead, this patch switches to a cleaner, more C++-like, method:
      It defines a new "file" subclass, called "special_file", which implements
      all file operations except close(), with a default implementation identical
      to the old unsupported.h implementations.
      
      The files of pipe(), socketpair(), timerfd() and epoll_create() now inherit
      from special_file, and only override the file operations they really want
      to implement.
      
      Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
      Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
      9478a14d
  4. Dec 31, 2013
  5. Dec 30, 2013
  6. Dec 27, 2013
  7. Dec 26, 2013
  8. Dec 24, 2013
  9. Dec 23, 2013
  10. Dec 20, 2013
  11. Dec 19, 2013
Loading