[haiku-commits] haiku: hrev50439 - src/system/kernel/arch/m68k headers/private/kernel/arch/m68k src/system/kernel/arch/m68k/paging src/system/kernel/platform/atari_m68k build/jam/repositories/HaikuPortsCross

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 20 Jul 2016 22:10:30 +0200 (CEST)

hrev50439 adds 14 changesets to branch 'master'
old head: d704be3579ab6e6cec447af591ac3ae7961fe223
new head: 02283e080cbb1857cacde56e9c67b1ae90ab852a
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=02283e080cbb+%5Ed704be3579ab

----------------------------------------------------------------------------

47a20cd6d106: M68K: turn #warnings into comments in public headers
  
  The warnings made those headers and those including them not detectable
  by libiberty's configure because of the way it checked for them.
  
  This fixes the gcc build.

3805f7222550: M68K: add arch_atomic.h

58820fadb127: M68K: update bootstrap packages version

7ab9993a1855: M68K: Add missing defines
  
  No idea for cache level.
  
  On 030 and 040 a cache line is 16 bytes.

990d34efddb5: M68K: add arch_cpu_idle and arch_cpu_pause inline stubs
  
  Remove the stub from arch_cpu.cpp
  
  We might want to implement a 040 CPU module providing idle using LPSTOP.

c094f0453745: M68K: dos2unix some files
  
  For some reason they used CR-LF.

d26fd5f68d11: M68K: drop the platform_type field, the enum is gone from OS.h

830fd19eb59b: M68K: Fix spinlock initialization

7cd7ba758c41: M68K: fix implicit casts of fault handler

a462159ce33f: M68K: Update to new system_info structures

9df4533caabb: M68K: use the updated atomic semantics
  
  * Use atomic_get_and_set to return the old value
  * Atomics are no longer volatile

ad4b06aa7520: m68k/paging: Convert to new-style CPU management
  
  * Aka, post-scheduler changes
  * Luckily M68K paging code is very simular to x86 paging

169349c98f57: M68K: more SMP stubbing
  
  We'll very much likely never support SMP on M68K...
  (unless someone has an SMP machine to donate? :D)

02283e080cbb: M68K: drop the custom C arch_cpu_user_mem*() for the default impl
  
  I didn't notice there was a C++ version that didn't require writing asm.
  
  I'll have to write them anyway for speed someday.

                                          [ François Revol <revol@xxxxxxx> ]

----------------------------------------------------------------------------

19 files changed, 931 insertions(+), 937 deletions(-)
build/jam/repositories/HaikuPortsCross/m68k      |    7 +-
headers/posix/arch/m68k/arch_setjmp.h            |    2 +-
headers/posix/arch/m68k/signal.h                 |    2 +-
headers/private/kernel/arch/m68k/arch_atomic.h   |   41 +
headers/private/kernel/arch/m68k/arch_cpu.h      |   25 +
headers/private/kernel/arch/m68k/arch_platform.h |    8 +-
headers/private/kernel/arch/user_memory.h        |    2 +
src/system/kernel/arch/m68k/arch_cpu.cpp         |   99 --
src/system/kernel/arch/m68k/arch_int.cpp         |   11 +-
src/system/kernel/arch/m68k/arch_platform.cpp    |  174 ++-
.../kernel/arch/m68k/arch_real_time_clock.cpp    |    2 +-
src/system/kernel/arch/m68k/arch_smp.cpp         |   11 +
src/system/kernel/arch/m68k/arch_system_info.cpp |   40 +-
.../arch/m68k/paging/040/M68KPagingMethod040.h   |    2 +-
.../arch/m68k/paging/M68KPagingStructures.cpp    |    3 +-
.../arch/m68k/paging/M68KPagingStructures.h      |    6 +-
.../arch/m68k/paging/M68KVMTranslationMap.cpp    |   14 +-
.../m68k_physical_page_mapper_large_memory.cpp   |   11 +-
.../kernel/platform/atari_m68k/platform.cpp      | 1408 +++++++++---------

############################################################################

Commit:      47a20cd6d1066333069538849f25dad7be540df8
URL:         http://cgit.haiku-os.org/haiku/commit/?id=47a20cd6d106
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 16:27:21 2016 UTC

M68K: turn #warnings into comments in public headers

The warnings made those headers and those including them not detectable
by libiberty's configure because of the way it checked for them.

This fixes the gcc build.

----------------------------------------------------------------------------

diff --git a/headers/posix/arch/m68k/arch_setjmp.h 
b/headers/posix/arch/m68k/arch_setjmp.h
index 4aa8146..cb5483a 100644
--- a/headers/posix/arch/m68k/arch_setjmp.h
+++ b/headers/posix/arch/m68k/arch_setjmp.h
@@ -8,6 +8,6 @@
 
 #define _SETJMP_BUF_SZ (7+6+2+8*((96/8)/4))
 typedef int __jmp_buf[_SETJMP_BUF_SZ];
-#warning M68K: fix jmpbuf size
+/* TODO: #warning M68K: fix jmpbuf size */
 
 #endif /* _ARCH_SETJMP_H_ */
diff --git a/headers/posix/arch/m68k/signal.h b/headers/posix/arch/m68k/signal.h
index 6623e7a..078f610 100644
--- a/headers/posix/arch/m68k/signal.h
+++ b/headers/posix/arch/m68k/signal.h
@@ -17,7 +17,7 @@ struct vregs
                d0, d1, d2, d3, d4, d5, d6, d7,
                a0, a1, a2, a3, a4, a5, a6, a7;
        unchar  ccr;
-#warning M68K: fix floats in vregs, add missing stuff.
+/* TODO: #warning M68K: fix floats in vregs, add missing stuff. */
    double f0,                                         /* fp scratch */
              f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12,f13; /* fp volatile regs */
 };

############################################################################

Commit:      3805f722255012c1c7fcca70809df08140212434
URL:         http://cgit.haiku-os.org/haiku/commit/?id=3805f7222550
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 16:59:10 2016 UTC

M68K: add arch_atomic.h

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/arch/m68k/arch_atomic.h 
b/headers/private/kernel/arch/m68k/arch_atomic.h
new file mode 100644
index 0000000..11d9d79
--- /dev/null
+++ b/headers/private/kernel/arch/m68k/arch_atomic.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2014, Paweł Dziepak, pdziepak@xxxxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ *
+ * Authors:
+ *             François Revol <revol@xxxxxxx>
+ */
+#ifndef _KERNEL_ARCH_M68K_ATOMIC_H
+#define _KERNEL_ARCH_M68K_ATOMIC_H
+
+
+static inline void
+memory_read_barrier_inline(void)
+{
+       asm volatile ("nop;" : : : "memory");
+#warning M68k: check memory_read_barrier_inline (FNOP ?)
+}
+
+
+static inline void
+memory_write_barrier_inline(void)
+{
+       asm volatile ("nop;" : : : "memory");
+#warning M68k: check memory_write_barrier_inline (FNOP ?)
+}
+
+
+static inline void
+memory_full_barrier_inline(void)
+{
+       asm volatile ("nop;" : : : "memory");
+#warning M68k: check memory_full_barrier_inline (FNOP ?)
+}
+
+
+#define memory_read_barrier memory_read_barrier_inline
+#define memory_write_barrier memory_write_barrier_inline
+#define memory_full_barrier memory_full_barrier_inline
+
+
+#endif // _KERNEL_ARCH_M68K_ATOMIC_H

############################################################################

Commit:      58820fadb127f72672b7a7a29d11877475c10a61
URL:         http://cgit.haiku-os.org/haiku/commit/?id=58820fadb127
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 17:54:32 2016 UTC

M68K: update bootstrap packages version

----------------------------------------------------------------------------

diff --git a/build/jam/repositories/HaikuPortsCross/m68k 
b/build/jam/repositories/HaikuPortsCross/m68k
index cea918b..79a337c 100644
--- a/build/jam/repositories/HaikuPortsCross/m68k
+++ b/build/jam/repositories/HaikuPortsCross/m68k
@@ -5,11 +5,12 @@ BootstrapPackageRepository HaikuPortsCross
        haikuporter-0-1
        :
        # repository architecture packages (stage 0)
-       gcc_bootstrap-4.8.4_2014_12_21-1
-       gcc_bootstrap_syslibs-4.8.4_2014_12_21-1
-       gcc_bootstrap_syslibs_devel-4.8.4_2014_12_21-1
+       gcc_bootstrap-5.4.0_2016_06_04-1
+       gcc_bootstrap_syslibs-5.4.0_2016_06_04-1
+       gcc_bootstrap_syslibs_devel-5.4.0_2016_06_04-1
        :
        # repository architecture packages (stage 1)
+       binutils_bootstrap-2.26.0_2016_02_29-1
        zlib_bootstrap-1.2.8-2
        zlib_bootstrap_devel-1.2.8-2
        :

############################################################################

Commit:      7ab9993a1855fc1de19f8ce218435fb08a1bddef
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7ab9993a1855
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 17:56:03 2016 UTC

M68K: Add missing defines

No idea for cache level.

On 030 and 040 a cache line is 16 bytes.

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/arch/m68k/arch_cpu.h 
b/headers/private/kernel/arch/m68k/arch_cpu.h
index ee6ad01..8e576a6 100644
--- a/headers/private/kernel/arch/m68k/arch_cpu.h
+++ b/headers/private/kernel/arch/m68k/arch_cpu.h
@@ -13,6 +13,11 @@
 #endif // !_ASSEMBLER
 
 
+#define CPU_MAX_CACHE_LEVEL    8
+
+#define CACHE_LINE_SIZE                16
+
+
 #define SR_IP_MASK 0x0700
 #define SR_S 0x2000
 #define M68K_SR_S 13

############################################################################

Commit:      990d34efddb51f003779c4f955da5f24d809da30
URL:         http://cgit.haiku-os.org/haiku/commit/?id=990d34efddb5
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 17:58:56 2016 UTC

M68K: add arch_cpu_idle and arch_cpu_pause inline stubs

Remove the stub from arch_cpu.cpp

We might want to implement a 040 CPU module providing idle using LPSTOP.

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/arch/m68k/arch_cpu.h 
b/headers/private/kernel/arch/m68k/arch_cpu.h
index 8e576a6..9d41e35 100644
--- a/headers/private/kernel/arch/m68k/arch_cpu.h
+++ b/headers/private/kernel/arch/m68k/arch_cpu.h
@@ -445,6 +445,26 @@ extern bool m68k_is_hw_register_readable(addr_t address);
 extern bool m68k_is_hw_register_writable(addr_t address, uint16 value);
        // defined in kernel: arch/m68k/cpu_asm.S
 
+
+static inline void
+arch_cpu_idle(void)
+{
+       // TODO: M68K CPU idle call
+       // there isn't really any insn for this. Maybe NOP/FNOP?
+       // TODO: make a 060 module using LPSTOP
+       //asm volatile ("lpstop");
+}
+
+
+static inline void
+arch_cpu_pause(void)
+{
+       // TODO: M68K STOP call
+       // the problem is STOP wants an immediate to put into SR
+       // but we don't want to overwrite it.
+       //asm volatile("stop #0" : : : "memory");
+}
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/src/system/kernel/arch/m68k/arch_cpu.cpp 
b/src/system/kernel/arch/m68k/arch_cpu.cpp
index 488e905..0eaeb49 100644
--- a/src/system/kernel/arch/m68k/arch_cpu.cpp
+++ b/src/system/kernel/arch/m68k/arch_cpu.cpp
@@ -268,16 +268,6 @@ arch_cpu_shutdown(bool reboot)
 }
 
 
-void
-arch_cpu_idle(void)
-{
-       if (cpu_ops.idle)
-               cpu_ops.idle();
-#warning M68K: use LPSTOP ?
-       //asm volatile ("lpstop");
-}
-
-
 // The purpose of this function is to trick the compiler. When setting the
 // page_handler to a label that is obviously (to the compiler) never used,
 // it may reorganize the control flow, so that the labeled part is optimized

############################################################################

Commit:      c094f04537450c0cc94e4dd55b2fafa175377302
URL:         http://cgit.haiku-os.org/haiku/commit/?id=c094f0453745
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 18:11:39 2016 UTC

M68K: dos2unix some files

For some reason they used CR-LF.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/m68k/arch_platform.cpp 
b/src/system/kernel/arch/m68k/arch_platform.cpp
index 8c57e8c..2f62c8c 100644
--- a/src/system/kernel/arch/m68k/arch_platform.cpp
+++ b/src/system/kernel/arch/m68k/arch_platform.cpp
@@ -1,88 +1,88 @@
-/*
- * Copyright 2007, François Revol, revol@xxxxxxx.
- * Distributed under the terms of the MIT License.
- *
- * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
- * All rights reserved. Distributed under the terms of the MIT License.
- */
-
-#include <arch_platform.h>
-
-#include <new>
-
-#include <KernelExport.h>
-
-#include <boot/kernel_args.h>
-//#include <platform/openfirmware/openfirmware.h>
-#include <real_time_clock.h>
-#include <util/kernel_cpp.h>
-
-
-static M68KPlatform *sM68KPlatform;
-
-
-// constructor
-M68KPlatform::M68KPlatform(platform_type platformType,
-       m68k_platform_type m68kPlatformType)
-       : fPlatformType(platformType),
-         fM68KPlatformType(m68kPlatformType)
-{
-}
-
-// destructor
-M68KPlatform::~M68KPlatform()
-{
-}
-
-// Default
-M68KPlatform *
-M68KPlatform::Default()
-{
-       return sM68KPlatform;
-}
-
-
-// # pragma mark -
-
-
-status_t
-arch_platform_init(struct kernel_args *kernelArgs)
-{
-       // only Atari supported for now
-       switch (kernelArgs->arch_args.platform) {
-#if 0
-               case M68K_PLATFORM_AMIGA:
-                       sM68KPlatform = instanciate_m68k_platform_amiga();
-                       break;
-#endif
-               case M68K_PLATFORM_ATARI:
-                       sM68KPlatform = instanciate_m68k_platform_atari();
-                       break;
-#if 0
-               case M68K_PLATFORM_MAC:
-                       sM68KPlatform = instanciate_m68k_platform_mac();
-                       break;
-               case M68K_PLATFORM_NEXT:
-                       sM68KPlatform = instanciate_m68k_platform_next();
-                       break;
-#endif
-               default:
-                       panic("unknown platform d\n", 
kernelArgs->arch_args.platform);
-       }
-
-       return sM68KPlatform->Init(kernelArgs);
-}
-
-
-status_t
-arch_platform_init_post_vm(struct kernel_args *kernelArgs)
-{
-       return sM68KPlatform->InitPostVM(kernelArgs);
-}
-
-
-status_t
-arch_platform_init_post_thread(struct kernel_args *kernelArgs)
-{
-       return B_OK;
-}
+/*
+ * Copyright 2007, François Revol, revol@xxxxxxx.
+ * Distributed under the terms of the MIT License.
+ *
+ * Copyright 2006, Ingo Weinhold <bonefish@xxxxxxxxxxxxxxx>.
+ * All rights reserved. Distributed under the terms of the MIT License.
+ */
+
+#include <arch_platform.h>
+
+#include <new>
+
+#include <KernelExport.h>
+
+#include <boot/kernel_args.h>
+//#include <platform/openfirmware/openfirmware.h>
+#include <real_time_clock.h>
+#include <util/kernel_cpp.h>
+
+
+static M68KPlatform *sM68KPlatform;
+
+
+// constructor
+M68KPlatform::M68KPlatform(platform_type platformType,
+       m68k_platform_type m68kPlatformType)
+       : fPlatformType(platformType),
+         fM68KPlatformType(m68kPlatformType)
+{
+}
+
+// destructor
+M68KPlatform::~M68KPlatform()
+{
+}
+
+// Default
+M68KPlatform *
+M68KPlatform::Default()
+{
+       return sM68KPlatform;
+}
+
+
+// # pragma mark -
+
+
+status_t
+arch_platform_init(struct kernel_args *kernelArgs)
+{
+       // only Atari supported for now
+       switch (kernelArgs->arch_args.platform) {
+#if 0
+               case M68K_PLATFORM_AMIGA:
+                       sM68KPlatform = instanciate_m68k_platform_amiga();
+                       break;
+#endif
+               case M68K_PLATFORM_ATARI:
+                       sM68KPlatform = instanciate_m68k_platform_atari();
+                       break;
+#if 0
+               case M68K_PLATFORM_MAC:
+                       sM68KPlatform = instanciate_m68k_platform_mac();
+                       break;
+               case M68K_PLATFORM_NEXT:
+                       sM68KPlatform = instanciate_m68k_platform_next();
+                       break;
+#endif
+               default:
+                       panic("unknown platform d\n", 
kernelArgs->arch_args.platform);
+       }
+
+       return sM68KPlatform->Init(kernelArgs);
+}
+
+
+status_t
+arch_platform_init_post_vm(struct kernel_args *kernelArgs)
+{
+       return sM68KPlatform->InitPostVM(kernelArgs);
+}
+
+
+status_t
+arch_platform_init_post_thread(struct kernel_args *kernelArgs)
+{
+       return B_OK;
+}
diff --git a/src/system/kernel/platform/atari_m68k/platform.cpp 
b/src/system/kernel/platform/atari_m68k/platform.cpp
index ccbd2a4..ace2f81 100644
--- a/src/system/kernel/platform/atari_m68k/platform.cpp
+++ b/src/system/kernel/platform/atari_m68k/platform.cpp
@@ -1,704 +1,704 @@
-/*
-       Atari kernel platform code.
-*/
-
-#include <arch_platform.h>
-
-#include <new>
-#include <util/kernel_cpp.h>
-
-#include <KernelExport.h>
-
-#include <boot/kernel_args.h>
-#include <arch/cpu.h>
-//#include <platform/openfirmware/openfirmware.h>
-#include <platform/atari_m68k/MFP.h>
-#include <platform/atari_m68k/platform_atari_m68k.h>
-#include <real_time_clock.h>
-#include <timer.h>
-
-#include "debugger_keymaps.h"
-
-/* which MFP timer to use */
-#define SYS_TDR                MFP_TADR
-#define SYS_TCR                MFP_TACR
-#define SYS_TCRMASK    0x0f    /* mask for timer control (0xf for A&B, 0x7 for 
C, 0x38 for D) */
-#define SYS_TENABLE    0x01    /* delay mode with /4 prescaler: 0x01 (<<3 for 
timer D) */
-#define SYS_TDISABLE   0x00
-#define SYS_TVECTOR    13
-#define MFP_PRESCALER  4
-
-/* used for timer interrupt */
-#define MFP_TIMER_RATE (MFP_FREQ/MFP_PRESCALER)
-#define MFP_MAX_TIMER_INTERVAL (0xff * 1000000L / MFP_TIMER_RATE)
-
-/* used for system_time() calculation */
-#define MFP_SYSTEM_TIME_RATE   (MFP_FREQ/MFP_PRESCALER)
-
-
-#define MFP0_BASE      0xFFFFFA00
-#define MFP1_BASE      0xFFFFFA80
-
-#define MFP0_VECTOR_BASE       64
-#define MFP1_VECTOR_BASE       (MFP0_VECTOR_BASE+16)
-
-#define TT_RTC_BASE    0xFFFF8960
-
-#define TT_RTC_VECTOR  (MFP1_VECTOR_BASE+14)
-
-// ?
-#define SCC_C0_VECTOR_BASE     (MFP1_VECTOR_BASE+16)
-// ??
-#define SCC_C1_VECTOR_BASE     (0x1BC/4)
-
-#define IKBD_BASE      0xFFFFFC00
-#define IKBD_CTRL      0
-#define IKBD_DATA      2
-#define IKBD_STATUS_READ_BUFFER_FULL   0x01
-
-// keyboard scancodes, very much like PC ones
-// see
-// http://www.classiccmp.org/dunfield/atw800/h/atw800k.jpg
-// ST Mag Nr 57 page 55
-enum keycodes {
-       LEFT_SHIFT              = 42,
-       RIGHT_SHIFT             = 54,
-
-       LEFT_CONTROL    = 29,
-
-       LEFT_ALT                = 56,
-
-       CURSOR_LEFT             = 75,
-       CURSOR_RIGHT    = 77,
-       CURSOR_UP               = 72,
-       CURSOR_DOWN             = 80,
-       CURSOR_HOME             = 71,
-       CURSOR_END              = 79,   // not on real atari keyboard
-       PAGE_UP                 = 73,   // not on real atari keyboard XXX remap 
Help ?
-       PAGE_DOWN               = 81,   // not on real atari keyboard XXX remap 
Undo ?
-
-       DELETE                  = 83,
-       F12                             = 88,   // but it's shifted
-
-};
-
-#define in8(a)  (*(volatile uint8 *)(a))
-#define out8(v, a)  (*(volatile uint8 *)(a) = v)
-
-
-namespace BPrivate {
-
-//class MfpPIC;
-
-// #pragma mark - Atari (Falcon)
-
-
-class M68KAtari : public M68KPlatform {
-public:
-       class MFP {
-       public:
-               MFP(uint32 base, int vector);
-               ~MFP();
-
-               uint32 Base() const { return fBase; };
-               int Vector() const { return fVector; };
-
-               uint8 ReadReg(uint32 reg) { return in8(fBase + reg); };
-               void WriteReg(uint32 reg, uint8 v) { out8(v, fBase + reg); };
-
-               void EnableIOInterrupt(int irq);
-               void DisableIOInterrupt(int irq);
-               bool AcknowledgeIOInterrupt(int irq);
-
-       private:
-               uint32 fBase;
-               int fVector;
-       };
-
-       class RTC {
-       public:
-               RTC(uint32 base, int vector);
-               ~RTC();
-
-               uint32 Base() const { return fBase; };
-               int Vector() const { return fVector; };
-
-               uint8 ReadReg(uint32 reg);
-               void WriteReg(uint32 reg, uint8 v) { out8((uint8)reg,fBase+1); 
out8(v,fBase+3); };
-
-       private:
-               uint32 fBase;
-               int fVector;
-       };
-
-       M68KAtari();
-       virtual ~M68KAtari();
-
-       void ProbeHardware(struct kernel_args *kernelArgs);
-
-       virtual status_t Init(struct kernel_args *kernelArgs);
-       virtual status_t InitSerialDebug(struct kernel_args *kernelArgs);
-       virtual status_t InitPostVM(struct kernel_args *kernelArgs);
-       virtual status_t InitPIC(struct kernel_args *kernelArgs);
-       virtual status_t InitRTC(struct kernel_args *kernelArgs,
-               struct real_time_data *data);
-       virtual status_t InitTimer(struct kernel_args *kernelArgs);
-
-       virtual char BlueScreenGetChar();
-
-       virtual char SerialDebugGetChar();
-       virtual void SerialDebugPutChar(char c);
-
-       virtual void EnableIOInterrupt(int irq);
-       virtual void DisableIOInterrupt(int irq);
-       virtual bool AcknowledgeIOInterrupt(int irq);
-
-       virtual uint8 ReadRTCReg(uint8 reg);
-       virtual void WriteRTCReg(uint8 reg, uint8 val);
-       virtual void SetHardwareRTC(uint32 seconds);
-       virtual uint32 GetHardwareRTC();
-
-       virtual void SetHardwareTimer(bigtime_t timeout);
-       virtual void ClearHardwareTimer(void);
-
-       virtual void ShutDown(bool reboot);
-
-private:
-       MFP     *MFPForIrq(int irq);
-       static int32    MFPTimerInterrupt(void *data);
-
-       MFP     *fMFP[2];
-
-       RTC     *fRTC;
-
-       // native features (ARAnyM emulator)
-       uint32 (*nfGetID)(const char *name);
-       int32 (*nfCall)(uint32 ID, ...);
-       char *nfPage;
-       uint32 nfDebugPrintfID;
-       
-};
-
-
-}      // namespace BPrivate
-
-using BPrivate::M68KAtari;
-
-
-// #pragma mark - M68KAtari::MFP
-
-
-static char sMFP0Buffer[sizeof(M68KAtari::MFP)];
-static char sMFP1Buffer[sizeof(M68KAtari::MFP)];
-
-// constructor
-M68KAtari::MFP::MFP(uint32 base, int vector)
-{
-       fBase = base;
-       fVector = vector;
-}
-
-
-M68KAtari::MFP::~MFP()
-{
-}
-
-#warning M68K: use enable or mark register ?
-
-void
-M68KAtari::MFP::EnableIOInterrupt(int irq)
-{
-       uint8 bit = 1 << (irq % 8);
-       // I*B[0] is vector+0, I*A[0] is vector+8
-       uint32 reg = Base() + ((irq > 8) ? (MFP_IERA) : (MFP_IERB));
-       uint8 val = in8(reg);
-       if (val & bit == 0) {
-               val |= bit;
-               out8(val, reg);
-       }
-}
-
-
-void
-M68KAtari::MFP::DisableIOInterrupt(int irq)
-{
-       uint8 bit = 1 << (irq % 8);
-       // I*B[0] is vector+0, I*A[0] is vector+8
-       uint32 reg = Base() + ((irq > 8) ? (MFP_IERA) : (MFP_IERB));
-       uint8 val = in8(reg);
-       if (val & bit) {
-               val &= ~bit;
-               out8(val, reg);
-       }
-}
-
-
-bool
-M68KAtari::MFP::AcknowledgeIOInterrupt(int irq)
-{
-       uint8 bit = 1 << (irq % 8);
-       // I*B[0] is vector+0, I*A[0] is vector+8
-       uint32 reg = Base() + ((irq > 8) ? (MFP_ISRA) : (MFP_ISRB));
-       uint8 val = in8(reg);
-       if (val & bit) {
-               val &= ~bit;
-               out8(val, reg);
-               return true;
-       }
-       return false;
-}
-
-
-// #pragma mark - M68KAtari::RTc
-
-
-static char sRTCBuffer[sizeof(M68KAtari::RTC)];
-
-// constructor
-M68KAtari::RTC::RTC(uint32 base, int vector)
-{
-       fBase = base;
-       fVector = vector;
-}
-
-
-M68KAtari::RTC::~RTC()
-{
-}
-
-
-uint8
-M68KAtari::RTC::ReadReg(uint32 reg)
-{
-       int waitTime = 10000;
-
-       if (reg < 0x0a) {       // time of day stuff...
-                               // check for in progress updates before 
accessing
-               out8(0x0a, fBase+1);
-               while((in8(fBase+3) & 0x80) && --waitTime);
-       }
-       
-       out8((uint8)reg,fBase+1);
-       return in8(fBase+3);
-}
-
-
-// #pragma mark - M68KAtari
-
-
-// constructor
-M68KAtari::M68KAtari()
-       : M68KPlatform(B_ATARI_PLATFORM, M68K_PLATFORM_ATARI)
-{
-}
-
-
-// destructor
-M68KAtari::~M68KAtari()
-{
-}
-
-
-void
-M68KAtari::ProbeHardware(struct kernel_args *kernelArgs)
-{
-       dprintf("Atari hardware:\n");
-       // if we are here we already know we have one
-       dprintf("       ST MFP\n");
-       if (m68k_is_hw_register_readable(MFP1_BASE)) {
-               dprintf("       TT MFP\n");
-               fMFP[1] = new(sMFP1Buffer) M68KAtari::MFP(MFP1_BASE, 
MFP1_VECTOR_BASE);
-       }
-       if (m68k_is_hw_register_readable(TT_RTC_BASE)) {
-               dprintf("       TT RTC MC146818A\n");
-               fRTC = new(sRTCBuffer) 
M68KAtari::RTC(TT_RTC_BASE,TT_RTC_VECTOR);
-       } else
-               panic("TT RTC required!");
-}
-
-
-status_t
-M68KAtari::Init(struct kernel_args *kernelArgs)
-{
-       fMFP[0] = NULL;
-       fMFP[1] = NULL;
-       fRTC = NULL;
-
-       // initialize ARAnyM NatFeatures
-       nfGetID =
-               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_get_id;
-       nfCall = 
-               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_call;
-       nfPage = (char *)
-               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_page;
-
-       // probe for ST-MFP
-       if (m68k_is_hw_register_readable(MFP0_BASE)) {
-               fMFP[0] = new(sMFP0Buffer) M68KAtari::MFP(MFP0_BASE, 
MFP0_VECTOR_BASE);
-       } else
-               // won't really work anyway from here
-               panic("You MUST have an ST MFP! Wait, is that *really* an Atari 
???");
-       
-       return B_OK;
-}
-
-
-status_t
-M68KAtari::InitSerialDebug(struct kernel_args *kernelArgs)
-{
-       nfDebugPrintfID =
-               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_dprintf_id;
-
-#warning M68K: add real serial debug output someday
-
-       //out8(0x11, IKBD_BASE+IKBD_DATA);
-
-       // now we can expect to see something
-       ProbeHardware(kernelArgs);
-
-       return B_OK;
-}
-
-
-status_t
-M68KAtari::InitPostVM(struct kernel_args *kernelArgs)
-{
-#if 0
-       add_debugger_command("of_exit", &debug_command_of_exit,
-               "Exit to the Open Firmware prompt. No way to get back into the 
OS!");
-       add_debugger_command("of_enter", &debug_command_of_enter,
-               "Enter a subordinate Open Firmware interpreter. Quitting it 
returns "
-               "to KDL.");
-#endif
-       return B_NO_INIT;
-       return B_OK;
-}
-
-
-status_t
-M68KAtari::InitPIC(struct kernel_args *kernelArgs)
-{
-       return B_OK;
-}
-
-
-status_t
-M68KAtari::InitRTC(struct kernel_args *kernelArgs,
-       struct real_time_data *data)
-{
-       // XXX we should do this in the bootloader maybe...
-       kernelArgs->arch_args.time_base_frequency = MFP_SYSTEM_TIME_RATE;
-       return B_OK;
-}
-
-
-status_t
-M68KAtari::InitTimer(struct kernel_args *kernelArgs)
-{
-       
-       fMFP[0]->WriteReg(MFP_TACR, 0); // stop it
-       install_io_interrupt_handler(fMFP[0]->Vector()+13, &MFPTimerInterrupt, 
this, 0);
-       return B_OK;
-}
-
-
-char
-M68KAtari::BlueScreenGetChar()
-{
-       /* polling the keyboard, similar to code in keyboard
-        * driver, but without using an interrupt
-        * taken almost straight from x86 code
-        * XXX: maybe use the keymap from the _AKP cookie instead ?
-        */
-       static bool shiftPressed = false;
-       static bool controlPressed = false;
-       static bool altPressed = false;
-       static uint8 special = 0;
-       static uint8 special2 = 0;
-       uint8 key = 0;
-
-       if (special & 0x80) {
-               special &= ~0x80;
-               return '[';
-       }
-       if (special != 0) {
-               key = special;
-               special = 0;
-               return key;
-       }
-       if (special2 != 0) {
-               key = special2;
-               special2 = 0;
-               return key;
-       }
-
-       while (true) {
-               uint8 status = in8(IKBD_BASE+IKBD_CTRL);
-
-               if ((status & IKBD_STATUS_READ_BUFFER_FULL) == 0) {
-                       // no data in keyboard buffer
-                       spin(200);
-                       //kprintf("no key\n");
-                       continue;
-               }
-
-               spin(200);
-               key = in8(IKBD_BASE+IKBD_DATA);
-               /*
-               kprintf("key: %02x, %sshift %scontrol %salt\n",
-                       key,
-                       shiftPressed?"":"!",
-                       controlPressed?"":"!",
-                       altPressed?"":"!");
-               */
-
-               if (key & 0x80) {
-                       // key up
-                       switch (key & ~0x80) {
-                               case LEFT_SHIFT:
-                               case RIGHT_SHIFT:
-                                       shiftPressed = false;
-                                       break;
-                               case LEFT_CONTROL:
-                                       controlPressed = false;
-                                       break;
-                               case LEFT_ALT:
-                                       altPressed = false;
-                                       break;
-                       }
-               } else {
-                       // key down
-                       switch (key) {
-                               case LEFT_SHIFT:
-                               case RIGHT_SHIFT:
-                                       shiftPressed = true;
-                                       break;
-
-                               case LEFT_CONTROL:
-                                       controlPressed = true;
-                                       break;
-
-                               case LEFT_ALT:
-                                       altPressed = true;
-                                       break;
-
-                               // start escape sequence for cursor movement
-                               case CURSOR_UP:
-                                       special = 0x80 | 'A';
-                                       return '\x1b';
-                               case CURSOR_DOWN:
-                                       special = 0x80 | 'B';
-                                       return '\x1b';
-                               case CURSOR_RIGHT:
-                                       special = 0x80 | 'C';
-                                       return '\x1b';
-                               case CURSOR_LEFT:
-                                       special = 0x80 | 'D';
-                                       return '\x1b';
-                               case CURSOR_HOME:
-                                       special = 0x80 | 'H';
-                                       return '\x1b';
-                               case CURSOR_END:
-                                       special = 0x80 | 'F';
-                                       return '\x1b';
-                               case PAGE_UP:
-                                       special = 0x80 | '5';
-                                       special2 = '~';
-                                       return '\x1b';
-                               case PAGE_DOWN:
-                                       special = 0x80 | '6';
-                                       special2 = '~';
-                                       return '\x1b';
-
-
-                               case DELETE:
-                                       if (controlPressed && altPressed)
-                                               arch_cpu_shutdown(true);
-
-                                       special = 0x80 | '3';
-                                       special2 = '~';
-                                       return '\x1b';
-
-                               default:
-                                       if (controlPressed) {
-                                               char c = kShiftedKeymap[key];
-                                               if (c >= 'A' && c <= 'Z')
-                                                       return 0x1f & c;
-                                       }
-
-                                       if (altPressed)
-                                               return kAltedKeymap[key];
-
-                                       return shiftPressed
-                                               ? kShiftedKeymap[key] : 
kUnshiftedKeymap[key];
-                       }
-               }
-       }
-}
-
-
-char
-M68KAtari::SerialDebugGetChar()
-{
-       //WRITEME
-       return BlueScreenGetChar();
-       //return 0;
-}
-
-
-void
-M68KAtari::SerialDebugPutChar(char c)
-{
-       if (nfCall && nfDebugPrintfID) {
-#if 0
-               static char buffer[2] = { '\0', '\0' };
-               buffer[0] = c;
-               
-               nfCall(nfDebugPrintfID /*| 0*/, buffer);
-#endif
-               nfPage[0] = c;
-               nfPage[1] = '\0';
-               nfCall(nfDebugPrintfID /*| 0*/, nfPage);
-       }
-
-#warning M68K: WRITEME
-       // real serial
-       //panic("WRITEME");
-}
-
-
-void
-M68KAtari::EnableIOInterrupt(int irq)
-{
-       MFP *mfp = MFPForIrq(irq);
-
-       if (mfp)
-               mfp->EnableIOInterrupt(irq - mfp->Vector());
-}
-
-
-void
-M68KAtari::DisableIOInterrupt(int irq)
-{
-       MFP *mfp = MFPForIrq(irq);
-
-       if (mfp)
-               mfp->DisableIOInterrupt(irq - mfp->Vector());
-}
-
-
-bool
-M68KAtari::AcknowledgeIOInterrupt(int irq)
-{
-       MFP *mfp = MFPForIrq(irq);
-
-       if (mfp)
-               return mfp->AcknowledgeIOInterrupt(irq - mfp->Vector());
-       return false;
-}
-
-
-uint8
-M68KAtari::ReadRTCReg(uint8 reg)
-{
-       // fake century
-       // (on MC146818A it's in the RAM, but probably it's used for that 
purpose...)
-       // but just in case, we're in 20xx now anyway :)
-       if (reg == 0x32)
-               return 0x20;
-       return fRTC->ReadReg(reg);
-}
-
-
-void
-M68KAtari::WriteRTCReg(uint8 reg, uint8 val)
-{
-       fRTC->WriteReg(reg, val);
-}
-
-void
-M68KAtari::SetHardwareRTC(uint32 seconds)
-{
-#warning M68K: WRITEME
-}
-
-
-uint32
-M68KAtari::GetHardwareRTC()
-{
-#warning M68K: WRITEME
-       return 0;
-}
-
-
-void
-M68KAtari::SetHardwareTimer(bigtime_t timeout)
-{
-       uint8 nextEventClocks;
-       if (timeout <= 0)
-               nextEventClocks = 2;
-       else if (timeout < MFP_MAX_TIMER_INTERVAL)
-               nextEventClocks = timeout * MFP_TIMER_RATE / 1000000;
-       else
-               nextEventClocks = 0xff;
-
-       fMFP[0]->WriteReg(SYS_TDR, nextEventClocks);
-       // delay mode, device by 4
-       fMFP[0]->WriteReg(SYS_TCR, (fMFP[0]->ReadReg(SYS_TCR) & SYS_TCRMASK) | 
SYS_TENABLE);
-       // enable irq
-       EnableIOInterrupt(MFP1_VECTOR_BASE + SYS_TVECTOR);
-}
-
-
-void
-M68KAtari::ClearHardwareTimer(void)
-{
-       // disable the irq (as on PC but I'm not sure it's needed)
-       DisableIOInterrupt(MFP1_VECTOR_BASE + SYS_TVECTOR);
-       // stop it, we don't want another countdown
-       fMFP[0]->WriteReg(SYS_TCR, (fMFP[0]->ReadReg(SYS_TCR) & SYS_TCRMASK) | 
SYS_TDISABLE);
-}
-
-
-void
-M68KAtari::ShutDown(bool reboot)
-{
-       panic("Bombs!");
-       panic("WRITEME");
-}
-
-
-M68KAtari::MFP *
-M68KAtari::MFPForIrq(int irq)
-{
-       int i;
-
-       for (i = 0; i < 2; i++) {
-               if (fMFP[i]) {
-                       if (irq >= fMFP[i]->Vector() && irq < fMFP[i]->Vector() 
+ 16)
-                               return fMFP[i];
-               }
-       }
-       return NULL;
-}
-
-int32
-M68KAtari::MFPTimerInterrupt(void *data)
-{
-       M68KAtari *_this = (M68KAtari *)data;
-       // disable the timer, else it will loop again with the same value
-       _this->ClearHardwareTimer();
-       // handle the timer
-       return timer_interrupt();
-}
-
-
-// static buffer for constructing the actual M68KPlatform
-static char *sM68KPlatformBuffer[sizeof(M68KAtari)];
-#warning PTR HERE ???
-
-
-M68KPlatform *instanciate_m68k_platform_atari()
-{
-       return new(sM68KPlatformBuffer) M68KAtari;
-}
+/*
+       Atari kernel platform code.
+*/
+
+#include <arch_platform.h>
+
+#include <new>
+#include <util/kernel_cpp.h>
+
+#include <KernelExport.h>
+
+#include <boot/kernel_args.h>
+#include <arch/cpu.h>
+//#include <platform/openfirmware/openfirmware.h>
+#include <platform/atari_m68k/MFP.h>
+#include <platform/atari_m68k/platform_atari_m68k.h>
+#include <real_time_clock.h>
+#include <timer.h>
+
+#include "debugger_keymaps.h"
+
+/* which MFP timer to use */
+#define SYS_TDR                MFP_TADR
+#define SYS_TCR                MFP_TACR
+#define SYS_TCRMASK    0x0f    /* mask for timer control (0xf for A&B, 0x7 for 
C, 0x38 for D) */
+#define SYS_TENABLE    0x01    /* delay mode with /4 prescaler: 0x01 (<<3 for 
timer D) */
+#define SYS_TDISABLE   0x00
+#define SYS_TVECTOR    13
+#define MFP_PRESCALER  4
+
+/* used for timer interrupt */
+#define MFP_TIMER_RATE (MFP_FREQ/MFP_PRESCALER)
+#define MFP_MAX_TIMER_INTERVAL (0xff * 1000000L / MFP_TIMER_RATE)
+
+/* used for system_time() calculation */
+#define MFP_SYSTEM_TIME_RATE   (MFP_FREQ/MFP_PRESCALER)
+
+
+#define MFP0_BASE      0xFFFFFA00
+#define MFP1_BASE      0xFFFFFA80
+
+#define MFP0_VECTOR_BASE       64
+#define MFP1_VECTOR_BASE       (MFP0_VECTOR_BASE+16)
+
+#define TT_RTC_BASE    0xFFFF8960
+
+#define TT_RTC_VECTOR  (MFP1_VECTOR_BASE+14)
+
+// ?
+#define SCC_C0_VECTOR_BASE     (MFP1_VECTOR_BASE+16)
+// ??
+#define SCC_C1_VECTOR_BASE     (0x1BC/4)
+
+#define IKBD_BASE      0xFFFFFC00
+#define IKBD_CTRL      0
+#define IKBD_DATA      2
+#define IKBD_STATUS_READ_BUFFER_FULL   0x01
+
+// keyboard scancodes, very much like PC ones
+// see
+// http://www.classiccmp.org/dunfield/atw800/h/atw800k.jpg
+// ST Mag Nr 57 page 55
+enum keycodes {
+       LEFT_SHIFT              = 42,
+       RIGHT_SHIFT             = 54,
+
+       LEFT_CONTROL    = 29,
+
+       LEFT_ALT                = 56,
+
+       CURSOR_LEFT             = 75,
+       CURSOR_RIGHT    = 77,
+       CURSOR_UP               = 72,
+       CURSOR_DOWN             = 80,
+       CURSOR_HOME             = 71,
+       CURSOR_END              = 79,   // not on real atari keyboard
+       PAGE_UP                 = 73,   // not on real atari keyboard XXX remap 
Help ?
+       PAGE_DOWN               = 81,   // not on real atari keyboard XXX remap 
Undo ?
+
+       DELETE                  = 83,
+       F12                             = 88,   // but it's shifted
+
+};
+
+#define in8(a)  (*(volatile uint8 *)(a))
+#define out8(v, a)  (*(volatile uint8 *)(a) = v)
+
+
+namespace BPrivate {
+
+//class MfpPIC;
+
+// #pragma mark - Atari (Falcon)
+
+
+class M68KAtari : public M68KPlatform {
+public:
+       class MFP {
+       public:
+               MFP(uint32 base, int vector);
+               ~MFP();
+
+               uint32 Base() const { return fBase; };
+               int Vector() const { return fVector; };
+
+               uint8 ReadReg(uint32 reg) { return in8(fBase + reg); };
+               void WriteReg(uint32 reg, uint8 v) { out8(v, fBase + reg); };
+
+               void EnableIOInterrupt(int irq);
+               void DisableIOInterrupt(int irq);
+               bool AcknowledgeIOInterrupt(int irq);
+
+       private:
+               uint32 fBase;
+               int fVector;
+       };
+
+       class RTC {
+       public:
+               RTC(uint32 base, int vector);
+               ~RTC();
+
+               uint32 Base() const { return fBase; };
+               int Vector() const { return fVector; };
+
+               uint8 ReadReg(uint32 reg);
+               void WriteReg(uint32 reg, uint8 v) { out8((uint8)reg,fBase+1); 
out8(v,fBase+3); };
+
+       private:
+               uint32 fBase;
+               int fVector;
+       };
+
+       M68KAtari();
+       virtual ~M68KAtari();
+
+       void ProbeHardware(struct kernel_args *kernelArgs);
+
+       virtual status_t Init(struct kernel_args *kernelArgs);
+       virtual status_t InitSerialDebug(struct kernel_args *kernelArgs);
+       virtual status_t InitPostVM(struct kernel_args *kernelArgs);
+       virtual status_t InitPIC(struct kernel_args *kernelArgs);
+       virtual status_t InitRTC(struct kernel_args *kernelArgs,
+               struct real_time_data *data);
+       virtual status_t InitTimer(struct kernel_args *kernelArgs);
+
+       virtual char BlueScreenGetChar();
+
+       virtual char SerialDebugGetChar();
+       virtual void SerialDebugPutChar(char c);
+
+       virtual void EnableIOInterrupt(int irq);
+       virtual void DisableIOInterrupt(int irq);
+       virtual bool AcknowledgeIOInterrupt(int irq);
+
+       virtual uint8 ReadRTCReg(uint8 reg);
+       virtual void WriteRTCReg(uint8 reg, uint8 val);
+       virtual void SetHardwareRTC(uint32 seconds);
+       virtual uint32 GetHardwareRTC();
+
+       virtual void SetHardwareTimer(bigtime_t timeout);
+       virtual void ClearHardwareTimer(void);
+
+       virtual void ShutDown(bool reboot);
+
+private:
+       MFP     *MFPForIrq(int irq);
+       static int32    MFPTimerInterrupt(void *data);
+
+       MFP     *fMFP[2];
+
+       RTC     *fRTC;
+
+       // native features (ARAnyM emulator)
+       uint32 (*nfGetID)(const char *name);
+       int32 (*nfCall)(uint32 ID, ...);
+       char *nfPage;
+       uint32 nfDebugPrintfID;
+       
+};
+
+
+}      // namespace BPrivate
+
+using BPrivate::M68KAtari;
+
+
+// #pragma mark - M68KAtari::MFP
+
+
+static char sMFP0Buffer[sizeof(M68KAtari::MFP)];
+static char sMFP1Buffer[sizeof(M68KAtari::MFP)];
+
+// constructor
+M68KAtari::MFP::MFP(uint32 base, int vector)
+{
+       fBase = base;
+       fVector = vector;
+}
+
+
+M68KAtari::MFP::~MFP()
+{
+}
+
+#warning M68K: use enable or mark register ?
+
+void
+M68KAtari::MFP::EnableIOInterrupt(int irq)
+{
+       uint8 bit = 1 << (irq % 8);
+       // I*B[0] is vector+0, I*A[0] is vector+8
+       uint32 reg = Base() + ((irq > 8) ? (MFP_IERA) : (MFP_IERB));
+       uint8 val = in8(reg);
+       if (val & bit == 0) {
+               val |= bit;
+               out8(val, reg);
+       }
+}
+
+
+void
+M68KAtari::MFP::DisableIOInterrupt(int irq)
+{
+       uint8 bit = 1 << (irq % 8);
+       // I*B[0] is vector+0, I*A[0] is vector+8
+       uint32 reg = Base() + ((irq > 8) ? (MFP_IERA) : (MFP_IERB));
+       uint8 val = in8(reg);
+       if (val & bit) {
+               val &= ~bit;
+               out8(val, reg);
+       }
+}
+
+
+bool
+M68KAtari::MFP::AcknowledgeIOInterrupt(int irq)
+{
+       uint8 bit = 1 << (irq % 8);
+       // I*B[0] is vector+0, I*A[0] is vector+8
+       uint32 reg = Base() + ((irq > 8) ? (MFP_ISRA) : (MFP_ISRB));
+       uint8 val = in8(reg);
+       if (val & bit) {
+               val &= ~bit;
+               out8(val, reg);
+               return true;
+       }
+       return false;
+}
+
+
+// #pragma mark - M68KAtari::RTc
+
+
+static char sRTCBuffer[sizeof(M68KAtari::RTC)];
+
+// constructor
+M68KAtari::RTC::RTC(uint32 base, int vector)
+{
+       fBase = base;
+       fVector = vector;
+}
+
+
+M68KAtari::RTC::~RTC()
+{
+}
+
+
+uint8
+M68KAtari::RTC::ReadReg(uint32 reg)
+{
+       int waitTime = 10000;
+
+       if (reg < 0x0a) {       // time of day stuff...
+                               // check for in progress updates before 
accessing
+               out8(0x0a, fBase+1);
+               while((in8(fBase+3) & 0x80) && --waitTime);
+       }
+       
+       out8((uint8)reg,fBase+1);
+       return in8(fBase+3);
+}
+
+
+// #pragma mark - M68KAtari
+
+
+// constructor
+M68KAtari::M68KAtari()
+       : M68KPlatform(B_ATARI_PLATFORM, M68K_PLATFORM_ATARI)
+{
+}
+
+
+// destructor
+M68KAtari::~M68KAtari()
+{
+}
+
+
+void
+M68KAtari::ProbeHardware(struct kernel_args *kernelArgs)
+{
+       dprintf("Atari hardware:\n");
+       // if we are here we already know we have one
+       dprintf("       ST MFP\n");
+       if (m68k_is_hw_register_readable(MFP1_BASE)) {
+               dprintf("       TT MFP\n");
+               fMFP[1] = new(sMFP1Buffer) M68KAtari::MFP(MFP1_BASE, 
MFP1_VECTOR_BASE);
+       }
+       if (m68k_is_hw_register_readable(TT_RTC_BASE)) {
+               dprintf("       TT RTC MC146818A\n");
+               fRTC = new(sRTCBuffer) 
M68KAtari::RTC(TT_RTC_BASE,TT_RTC_VECTOR);
+       } else
+               panic("TT RTC required!");
+}
+
+
+status_t
+M68KAtari::Init(struct kernel_args *kernelArgs)
+{
+       fMFP[0] = NULL;
+       fMFP[1] = NULL;
+       fRTC = NULL;
+
+       // initialize ARAnyM NatFeatures
+       nfGetID =
+               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_get_id;
+       nfCall = 
+               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_call;
+       nfPage = (char *)
+               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_page;
+
+       // probe for ST-MFP
+       if (m68k_is_hw_register_readable(MFP0_BASE)) {
+               fMFP[0] = new(sMFP0Buffer) M68KAtari::MFP(MFP0_BASE, 
MFP0_VECTOR_BASE);
+       } else
+               // won't really work anyway from here
+               panic("You MUST have an ST MFP! Wait, is that *really* an Atari 
???");
+       
+       return B_OK;
+}
+
+
+status_t
+M68KAtari::InitSerialDebug(struct kernel_args *kernelArgs)
+{
+       nfDebugPrintfID =
+               kernelArgs->arch_args.plat_args.atari.nat_feat.nf_dprintf_id;
+
+#warning M68K: add real serial debug output someday
+
+       //out8(0x11, IKBD_BASE+IKBD_DATA);
+
+       // now we can expect to see something
+       ProbeHardware(kernelArgs);
+
+       return B_OK;
+}
+
+
+status_t
+M68KAtari::InitPostVM(struct kernel_args *kernelArgs)
+{
+#if 0
+       add_debugger_command("of_exit", &debug_command_of_exit,
+               "Exit to the Open Firmware prompt. No way to get back into the 
OS!");
+       add_debugger_command("of_enter", &debug_command_of_enter,
+               "Enter a subordinate Open Firmware interpreter. Quitting it 
returns "
+               "to KDL.");
+#endif
+       return B_NO_INIT;
+       return B_OK;
+}
+
+
+status_t
+M68KAtari::InitPIC(struct kernel_args *kernelArgs)
+{
+       return B_OK;
+}
+
+
+status_t
+M68KAtari::InitRTC(struct kernel_args *kernelArgs,
+       struct real_time_data *data)
+{
+       // XXX we should do this in the bootloader maybe...
+       kernelArgs->arch_args.time_base_frequency = MFP_SYSTEM_TIME_RATE;
+       return B_OK;
+}
+
+
+status_t
+M68KAtari::InitTimer(struct kernel_args *kernelArgs)
+{
+       
+       fMFP[0]->WriteReg(MFP_TACR, 0); // stop it
+       install_io_interrupt_handler(fMFP[0]->Vector()+13, &MFPTimerInterrupt, 
this, 0);
+       return B_OK;
+}
+
+
+char
+M68KAtari::BlueScreenGetChar()
+{
+       /* polling the keyboard, similar to code in keyboard
+        * driver, but without using an interrupt
+        * taken almost straight from x86 code
+        * XXX: maybe use the keymap from the _AKP cookie instead ?
+        */
+       static bool shiftPressed = false;
+       static bool controlPressed = false;
+       static bool altPressed = false;
+       static uint8 special = 0;
+       static uint8 special2 = 0;
+       uint8 key = 0;
+
+       if (special & 0x80) {
+               special &= ~0x80;
+               return '[';
+       }
+       if (special != 0) {
+               key = special;
+               special = 0;
+               return key;
+       }
+       if (special2 != 0) {
+               key = special2;
+               special2 = 0;
+               return key;
+       }
+
+       while (true) {
+               uint8 status = in8(IKBD_BASE+IKBD_CTRL);
+
+               if ((status & IKBD_STATUS_READ_BUFFER_FULL) == 0) {
+                       // no data in keyboard buffer
+                       spin(200);
+                       //kprintf("no key\n");
+                       continue;
+               }
+
+               spin(200);
+               key = in8(IKBD_BASE+IKBD_DATA);
+               /*
+               kprintf("key: %02x, %sshift %scontrol %salt\n",
+                       key,
+                       shiftPressed?"":"!",
+                       controlPressed?"":"!",
+                       altPressed?"":"!");
+               */
+
+               if (key & 0x80) {
+                       // key up
+                       switch (key & ~0x80) {
+                               case LEFT_SHIFT:
+                               case RIGHT_SHIFT:
+                                       shiftPressed = false;
+                                       break;
+                               case LEFT_CONTROL:
+                                       controlPressed = false;
+                                       break;
+                               case LEFT_ALT:
+                                       altPressed = false;
+                                       break;
+                       }
+               } else {
+                       // key down
+                       switch (key) {
+                               case LEFT_SHIFT:
+                               case RIGHT_SHIFT:
+                                       shiftPressed = true;
+                                       break;
+
+                               case LEFT_CONTROL:
+                                       controlPressed = true;
+                                       break;
+
+                               case LEFT_ALT:
+                                       altPressed = true;
+                                       break;
+
+                               // start escape sequence for cursor movement
+                               case CURSOR_UP:
+                                       special = 0x80 | 'A';
+                                       return '\x1b';
+                               case CURSOR_DOWN:
+                                       special = 0x80 | 'B';
+                                       return '\x1b';
+                               case CURSOR_RIGHT:
+                                       special = 0x80 | 'C';
+                                       return '\x1b';
+                               case CURSOR_LEFT:
+                                       special = 0x80 | 'D';
+                                       return '\x1b';
+                               case CURSOR_HOME:
+                                       special = 0x80 | 'H';
+                                       return '\x1b';
+                               case CURSOR_END:
+                                       special = 0x80 | 'F';
+                                       return '\x1b';
+                               case PAGE_UP:
+                                       special = 0x80 | '5';
+                                       special2 = '~';
+                                       return '\x1b';
+                               case PAGE_DOWN:
+                                       special = 0x80 | '6';
+                                       special2 = '~';
+                                       return '\x1b';
+
+
+                               case DELETE:
+                                       if (controlPressed && altPressed)
+                                               arch_cpu_shutdown(true);
+
+                                       special = 0x80 | '3';
+                                       special2 = '~';
+                                       return '\x1b';
+
+                               default:
+                                       if (controlPressed) {
+                                               char c = kShiftedKeymap[key];
+                                               if (c >= 'A' && c <= 'Z')
+                                                       return 0x1f & c;
+                                       }
+
+                                       if (altPressed)
+                                               return kAltedKeymap[key];
+
+                                       return shiftPressed
+                                               ? kShiftedKeymap[key] : 
kUnshiftedKeymap[key];
+                       }
+               }
+       }
+}
+
+
+char
+M68KAtari::SerialDebugGetChar()
+{
+       //WRITEME
+       return BlueScreenGetChar();
+       //return 0;
+}
+
+
+void
+M68KAtari::SerialDebugPutChar(char c)
+{
+       if (nfCall && nfDebugPrintfID) {
+#if 0
+               static char buffer[2] = { '\0', '\0' };
+               buffer[0] = c;
+               
+               nfCall(nfDebugPrintfID /*| 0*/, buffer);
+#endif
+               nfPage[0] = c;
+               nfPage[1] = '\0';
+               nfCall(nfDebugPrintfID /*| 0*/, nfPage);
+       }
+
+#warning M68K: WRITEME
+       // real serial
+       //panic("WRITEME");
+}
+
+
+void
+M68KAtari::EnableIOInterrupt(int irq)
+{
+       MFP *mfp = MFPForIrq(irq);
+
+       if (mfp)
+               mfp->EnableIOInterrupt(irq - mfp->Vector());
+}
+
+
+void
+M68KAtari::DisableIOInterrupt(int irq)
+{
+       MFP *mfp = MFPForIrq(irq);
+
+       if (mfp)
+               mfp->DisableIOInterrupt(irq - mfp->Vector());
+}
+
+
+bool
+M68KAtari::AcknowledgeIOInterrupt(int irq)
+{
+       MFP *mfp = MFPForIrq(irq);
+
+       if (mfp)
+               return mfp->AcknowledgeIOInterrupt(irq - mfp->Vector());
+       return false;
+}
+
+
+uint8
+M68KAtari::ReadRTCReg(uint8 reg)
+{
+       // fake century
+       // (on MC146818A it's in the RAM, but probably it's used for that 
purpose...)
+       // but just in case, we're in 20xx now anyway :)
+       if (reg == 0x32)
+               return 0x20;
+       return fRTC->ReadReg(reg);
+}
+
+
+void
+M68KAtari::WriteRTCReg(uint8 reg, uint8 val)
+{
+       fRTC->WriteReg(reg, val);
+}
+
+void
+M68KAtari::SetHardwareRTC(uint32 seconds)
+{
+#warning M68K: WRITEME
+}
+
+
+uint32
+M68KAtari::GetHardwareRTC()
+{
+#warning M68K: WRITEME
+       return 0;
+}
+
+
+void
+M68KAtari::SetHardwareTimer(bigtime_t timeout)
+{
+       uint8 nextEventClocks;
+       if (timeout <= 0)
+               nextEventClocks = 2;
+       else if (timeout < MFP_MAX_TIMER_INTERVAL)
+               nextEventClocks = timeout * MFP_TIMER_RATE / 1000000;
+       else
+               nextEventClocks = 0xff;
+
+       fMFP[0]->WriteReg(SYS_TDR, nextEventClocks);
+       // delay mode, device by 4
+       fMFP[0]->WriteReg(SYS_TCR, (fMFP[0]->ReadReg(SYS_TCR) & SYS_TCRMASK) | 
SYS_TENABLE);
+       // enable irq
+       EnableIOInterrupt(MFP1_VECTOR_BASE + SYS_TVECTOR);
+}
+
+
+void
+M68KAtari::ClearHardwareTimer(void)
+{
+       // disable the irq (as on PC but I'm not sure it's needed)
+       DisableIOInterrupt(MFP1_VECTOR_BASE + SYS_TVECTOR);
+       // stop it, we don't want another countdown
+       fMFP[0]->WriteReg(SYS_TCR, (fMFP[0]->ReadReg(SYS_TCR) & SYS_TCRMASK) | 
SYS_TDISABLE);
+}
+
+
+void
+M68KAtari::ShutDown(bool reboot)
+{
+       panic("Bombs!");
+       panic("WRITEME");
+}
+
+
+M68KAtari::MFP *
+M68KAtari::MFPForIrq(int irq)
+{
+       int i;
+
+       for (i = 0; i < 2; i++) {
+               if (fMFP[i]) {
+                       if (irq >= fMFP[i]->Vector() && irq < fMFP[i]->Vector() 
+ 16)
+                               return fMFP[i];
+               }
+       }
+       return NULL;
+}
+
+int32
+M68KAtari::MFPTimerInterrupt(void *data)
+{
+       M68KAtari *_this = (M68KAtari *)data;
+       // disable the timer, else it will loop again with the same value
+       _this->ClearHardwareTimer();
+       // handle the timer
+       return timer_interrupt();
+}
+
+
+// static buffer for constructing the actual M68KPlatform
+static char *sM68KPlatformBuffer[sizeof(M68KAtari)];
+#warning PTR HERE ???
+
+
+M68KPlatform *instanciate_m68k_platform_atari()
+{
+       return new(sM68KPlatformBuffer) M68KAtari;
+}

############################################################################

Commit:      d26fd5f68d118a1eb7c752a2682c6f0c0b8ced15
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d26fd5f68d11
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 18:13:27 2016 UTC

M68K: drop the platform_type field, the enum is gone from OS.h

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/arch/m68k/arch_platform.h 
b/headers/private/kernel/arch/m68k/arch_platform.h
index 7c47183..2abb472 100644
--- a/headers/private/kernel/arch/m68k/arch_platform.h
+++ b/headers/private/kernel/arch/m68k/arch_platform.h
@@ -23,13 +23,12 @@ namespace BPrivate {
 
 class M68KPlatform {
 public:
-       M68KPlatform(platform_type platformType, m68k_platform_type 
m68kPlatformType);
+       M68KPlatform(m68k_platform_type platformType);
        virtual ~M68KPlatform();
 
        static M68KPlatform *Default();
 
-       inline platform_type PlatformType() const       { return fPlatformType; 
}
-       inline m68k_platform_type M68KPlatformType() const      { return 
fM68KPlatformType; }
+       inline m68k_platform_type PlatformType() const  { return fPlatformType; 
}
 
        virtual status_t Init(struct kernel_args *kernelArgs) = 0;
        virtual status_t InitSerialDebug(struct kernel_args *kernelArgs) = 0;
@@ -60,8 +59,7 @@ public:
        virtual void ShutDown(bool reboot) = 0;
 
 private:
-       m68k_platform_type      fM68KPlatformType;
-       platform_type   fPlatformType;
+       m68k_platform_type      fPlatformType;
 };
 
 
diff --git a/src/system/kernel/arch/m68k/arch_platform.cpp 
b/src/system/kernel/arch/m68k/arch_platform.cpp
index 2f62c8c..bf5003b 100644
--- a/src/system/kernel/arch/m68k/arch_platform.cpp
+++ b/src/system/kernel/arch/m68k/arch_platform.cpp
@@ -22,10 +22,8 @@ static M68KPlatform *sM68KPlatform;
 
 
 // constructor
-M68KPlatform::M68KPlatform(platform_type platformType,
-       m68k_platform_type m68kPlatformType)
-       : fPlatformType(platformType),
-         fM68KPlatformType(m68kPlatformType)
+M68KPlatform::M68KPlatform(m68k_platform_type platformType)
+       : fPlatformType(platformType)
 {
 }
 
diff --git a/src/system/kernel/platform/atari_m68k/platform.cpp 
b/src/system/kernel/platform/atari_m68k/platform.cpp
index ace2f81..fe6599c 100644
--- a/src/system/kernel/platform/atari_m68k/platform.cpp
+++ b/src/system/kernel/platform/atari_m68k/platform.cpp
@@ -288,7 +288,7 @@ M68KAtari::RTC::ReadReg(uint32 reg)
 
 // constructor
 M68KAtari::M68KAtari()
-       : M68KPlatform(B_ATARI_PLATFORM, M68K_PLATFORM_ATARI)
+       : M68KPlatform(M68K_PLATFORM_ATARI)
 {
 }
 

############################################################################

Commit:      830fd19eb59b512afbfa8f94afcf153780f02e06
URL:         http://cgit.haiku-os.org/haiku/commit/?id=830fd19eb59b
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 19:06:38 2016 UTC

M68K: Fix spinlock initialization

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/m68k/arch_real_time_clock.cpp 
b/src/system/kernel/arch/m68k/arch_real_time_clock.cpp
index 046ea60..e508a09 100644
--- a/src/system/kernel/arch/m68k/arch_real_time_clock.cpp
+++ b/src/system/kernel/arch/m68k/arch_real_time_clock.cpp
@@ -184,7 +184,7 @@ arch_rtc_init(kernel_args *args, struct real_time_data 
*data)
        data->arch_data.version = 0;
 
        // init spinlock
-       sSetArchDataLock = 0;
+       B_INITIALIZE_SPINLOCK(&sSetArchDataLock);
 
        // init system_time() conversion factor
        
__m68k_setup_system_time(&data->arch_data.system_time_conversion_factor);

############################################################################

Commit:      7cd7ba758c41a3f4e0518a62a460b282058b20d7
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7cd7ba758c41
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 19:07:26 2016 UTC

M68K: fix implicit casts of fault handler

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/m68k/arch_int.cpp 
b/src/system/kernel/arch/m68k/arch_int.cpp
index 788d56e..de3f079 100644
--- a/src/system/kernel/arch/m68k/arch_int.cpp
+++ b/src/system/kernel/arch/m68k/arch_int.cpp
@@ -197,7 +197,7 @@ m68k_exception_entry(struct iframe *iframe)
                        if (kernelDebugger) {
                                // if this thread has a fault handler, we're 
allowed to be here
                                if (thread && thread->fault_handler != 0) {
-                                       iframe->cpu.pc = thread->fault_handler;
+                                       iframe->cpu.pc = 
reinterpret_cast<addr_t>(thread->fault_handler);
                                        break;
                                }
 
@@ -215,7 +215,7 @@ m68k_exception_entry(struct iframe *iframe)
                                // disabled, which in most cases is a bug. We 
should add some thread
                                // flag allowing to explicitly indicate that 
this handling is desired.
                                if (thread && thread->fault_handler != 0) {
-                                       iframe->cpu.pc = thread->fault_handler;
+                                       iframe->cpu.pc = 
reinterpret_cast<addr_t>(thread->fault_handler);
                                                return;
                                }
 

############################################################################

Commit:      a462159ce33f0ff18f856959abd288f80720bba9
URL:         http://cgit.haiku-os.org/haiku/commit/?id=a462159ce33f
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 19:09:24 2016 UTC

M68K: Update to new system_info structures

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/m68k/arch_system_info.cpp 
b/src/system/kernel/arch/m68k/arch_system_info.cpp
index 3a20141..003cc32 100644
--- a/src/system/kernel/arch/m68k/arch_system_info.cpp
+++ b/src/system/kernel/arch/m68k/arch_system_info.cpp
@@ -19,35 +19,41 @@
 
 static uint64 sCPUClockFrequency;
 static uint64 sBusClockFrequency;
-static enum cpu_types sCPUType;
 static uint16 sCPURevision;
 
-status_t
-arch_get_system_info(system_info *info, size_t size)
-{
-       info->cpu_type = sCPUType;
-       info->cpu_revision = sCPURevision;
-
-       info->cpu_clock_speed = sCPUClockFrequency;
-       info->bus_clock_speed = sBusClockFrequency;
-
-       info->platform_type = M68KPlatform::Default()->PlatformType();
 
-       return B_OK;
+void
+arch_fill_topology_node(cpu_topology_node_info* node, int32 cpu)
+{
+       switch (node->type) {
+               case B_TOPOLOGY_ROOT:
+                       node->data.root.platform = B_CPU_M68K;
+                       break;
+
+               case B_TOPOLOGY_PACKAGE:
+                       node->data.package.vendor = B_CPU_VENDOR_MOTOROLA;
+                       node->data.package.cache_line_size = CACHE_LINE_SIZE;
+                       break;
+
+               case B_TOPOLOGY_CORE:
+                       node->data.core.model = sCPURevision;
+                       node->data.core.default_frequency = sCPUClockFrequency;
+                       break;
+
+               default:
+                       break;
+       }
 }
 
 
 status_t
 arch_system_info_init(struct kernel_args *args)
 {
-       int i;
-
        sCPUClockFrequency = args->arch_args.cpu_frequency;
-       sBusClockFrequency = args->arch_args.bus_frequency;
+       sBusClockFrequency = args->arch_args.bus_frequency; // not reported 
anymore?
 
-       sCPURevision = args->arch_args.cpu_type; //XXX
+       sCPURevision = args->arch_args.cpu_type; //TODO:is it what we want?
 #warning M68K: use 060 PCR[15:8]
-       sCPUType = B_CPU_M68K;
        
        return B_OK;
 }

############################################################################

Commit:      9df4533caabb9f7009b791e3c528c0774bbc2e5f
URL:         http://cgit.haiku-os.org/haiku/commit/?id=9df4533caabb
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 19:08:08 2016 UTC

M68K: use the updated atomic semantics

* Use atomic_get_and_set to return the old value
* Atomics are no longer volatile

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h 
b/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h
index 0e10b15..786104a 100644
--- a/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h
+++ b/src/system/kernel/arch/m68k/paging/040/M68KPagingMethod040.h
@@ -122,7 +122,7 @@ M68KPagingMethod040::Method()
 M68KPagingMethod040::SetPageTableEntry(page_table_entry* entry,
        page_table_entry newEntry)
 {
-       return atomic_set((int32*)entry, newEntry);
+       return atomic_get_and_set((int32*)entry, newEntry);
 }
 
 
diff --git a/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h 
b/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h
index d53b6d2..dfd8615 100644
--- a/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h
+++ b/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h
@@ -17,7 +17,7 @@
 
 struct M68KPagingStructures : DeferredDeletable {
        uint32                                          pgroot_phys;
-       vint32                                          ref_count;
+       int32                                           ref_count;
        vint32                                          active_on_cpus;
                // mask indicating on which CPUs the map is currently used
 

############################################################################

Commit:      ad4b06aa7520feac8eee4c03a11fb6d77417b5ba
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ad4b06aa7520
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 19:28:56 2016 UTC

m68k/paging: Convert to new-style CPU management

* Aka, post-scheduler changes
* Luckily M68K paging code is very simular to x86 paging

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/m68k/paging/M68KPagingStructures.cpp 
b/src/system/kernel/arch/m68k/paging/M68KPagingStructures.cpp
index 650ded5..203a80f 100644
--- a/src/system/kernel/arch/m68k/paging/M68KPagingStructures.cpp
+++ b/src/system/kernel/arch/m68k/paging/M68KPagingStructures.cpp
@@ -9,8 +9,7 @@
 
 M68KPagingStructures::M68KPagingStructures()
        :
-       ref_count(1),
-       active_on_cpus(0)
+       ref_count(1)
 {
 }
 
diff --git a/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h 
b/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h
index dfd8615..6904fb6 100644
--- a/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h
+++ b/src/system/kernel/arch/m68k/paging/M68KPagingStructures.h
@@ -14,11 +14,13 @@
 
 #include <heap.h>
 
+#include <smp.h>
+
 
 struct M68KPagingStructures : DeferredDeletable {
        uint32                                          pgroot_phys;
        int32                                           ref_count;
-       vint32                                          active_on_cpus;
+       CPUSet                                          active_on_cpus;
                // mask indicating on which CPUs the map is currently used
 
                                                                
M68KPagingStructures();
diff --git a/src/system/kernel/arch/m68k/paging/M68KVMTranslationMap.cpp 
b/src/system/kernel/arch/m68k/paging/M68KVMTranslationMap.cpp
index 47fc0b2..54edf44 100644
--- a/src/system/kernel/arch/m68k/paging/M68KVMTranslationMap.cpp
+++ b/src/system/kernel/arch/m68k/paging/M68KVMTranslationMap.cpp
@@ -113,9 +113,10 @@ M68KVMTranslationMap::Flush()
                        restore_interrupts(state);
 
                        int cpu = smp_get_current_cpu();
-                       uint32 cpuMask = PagingStructures()->active_on_cpus
-                               & ~((uint32)1 << cpu);
-                       if (cpuMask != 0) {
+                       CPUSet cpuMask = PagingStructures()->active_on_cpus;
+                       cpuMask.ClearBit(cpu);
+
+                       if (!cpuMask.IsEmpty()) {
                                smp_send_multicast_ici(cpuMask, 
SMP_MSG_USER_INVALIDATE_PAGES,
                                        0, 0, 0, NULL, SMP_MSG_FLAG_SYNC);
                        }
@@ -132,9 +133,10 @@ M68KVMTranslationMap::Flush()
                                SMP_MSG_FLAG_SYNC);
                } else {
                        int cpu = smp_get_current_cpu();
-                       uint32 cpuMask = PagingStructures()->active_on_cpus
-                               & ~((uint32)1 << cpu);
-                       if (cpuMask != 0) {
+                       CPUSet cpuMask = PagingStructures()->active_on_cpus;
+                       cpuMask.ClearBit(cpu);
+
+                       if (!cpuMask.IsEmpty()) {
                                smp_send_multicast_ici(cpuMask, 
SMP_MSG_INVALIDATE_PAGE_LIST,
                                        (addr_t)fInvalidPages, 
fInvalidPagesCount, 0, NULL,
                                        SMP_MSG_FLAG_SYNC);
diff --git 
a/src/system/kernel/arch/m68k/paging/m68k_physical_page_mapper_large_memory.cpp 
b/src/system/kernel/arch/m68k/paging/m68k_physical_page_mapper_large_memory.cpp
index 7eabfac..e3507a3 100644
--- 
a/src/system/kernel/arch/m68k/paging/m68k_physical_page_mapper_large_memory.cpp
+++ 
b/src/system/kernel/arch/m68k/paging/m68k_physical_page_mapper_large_memory.cpp
@@ -113,7 +113,7 @@ private:
                        struct page_slot {
                                PhysicalPageSlot*       slot;
                                phys_addr_t                     physicalAddress;
-                               cpu_mask_t                      valid;
+                               CPUSet                          valid;
                        };
 
                        page_slot                       
fSlots[SLOTS_PER_TRANSLATION_MAP];
@@ -175,7 +175,7 @@ private:
                        PhysicalPageSlot* fDebugSlot;
                        PhysicalPageSlotPool* fInitialPool;
                        LargeMemoryTranslationMapPhysicalPageMapper     
fKernelMapper;
-                       PhysicalPageOpsCPUData fPerCPUData[B_MAX_CPU_COUNT];
+                       PhysicalPageOpsCPUData fPerCPUData[SMP_MAX_CPUS];
 };
 
 static LargeMemoryPhysicalPageMapper sPhysicalPageMapper;
@@ -396,11 +396,11 @@ 
LargeMemoryTranslationMapPhysicalPageMapper::GetPageTableAt(
                page_slot& slot = fSlots[i];
                if (slot.physicalAddress == physicalAddress) {
                        fNextSlot = (i + 1) & (fSlotCount - 1);
-                       if ((slot.valid & (1 << currentCPU)) == 0) {
+                       if ((slot.valid.GetBit(currentCPU)) == 0) {
                                // not valid on this CPU -- invalidate the TLB 
entry
                                
arch_cpu_invalidate_TLB_range(slot.slot->address,
                                        slot.slot->address);
-                               slot.valid |= 1 << currentCPU;
+                               slot.valid.SetBit(currentCPU);
                        }
                        return (void*)slot.slot->address;
                }
@@ -412,7 +412,8 @@ LargeMemoryTranslationMapPhysicalPageMapper::GetPageTableAt(
 
        slot.physicalAddress = physicalAddress;
        slot.slot->Map(physicalAddress);
-       slot.valid = 1 << currentCPU;
+       slot.valid.ClearAll();
+       slot.valid.SetBit(currentCPU);
 
        return (void*)slot.slot->address;
 }

############################################################################

Commit:      169349c98f57619a6991271cad55be8923b60568
URL:         http://cgit.haiku-os.org/haiku/commit/?id=169349c98f57
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 19:56:15 2016 UTC

M68K: more SMP stubbing

We'll very much likely never support SMP on M68K...
(unless someone has an SMP machine to donate? :D)

----------------------------------------------------------------------------

diff --git a/src/system/kernel/arch/m68k/arch_int.cpp 
b/src/system/kernel/arch/m68k/arch_int.cpp
index de3f079..6583b75 100644
--- a/src/system/kernel/arch/m68k/arch_int.cpp
+++ b/src/system/kernel/arch/m68k/arch_int.cpp
@@ -95,6 +95,13 @@ arch_int_disable_io_interrupt(int irq)
 /* arch_int_*_interrupts() and friends are in arch_asm.S */
 
 
+void
+arch_int_assign_to_cpu(int32 irq, int32 cpu)
+{
+       // intentionally left blank; no SMP support (yet)
+}
+
+
 static void
 print_iframe(struct iframe *frame)
 {
diff --git a/src/system/kernel/arch/m68k/arch_smp.cpp 
b/src/system/kernel/arch/m68k/arch_smp.cpp
index 3a14e96..3c61396 100644
--- a/src/system/kernel/arch/m68k/arch_smp.cpp
+++ b/src/system/kernel/arch/m68k/arch_smp.cpp
@@ -15,6 +15,7 @@
 #include <boot/stage2.h>
 #include <arch/smp.h>
 #include <debug.h>
+#include <int.h>
 
 
 status_t
@@ -32,6 +33,16 @@ arch_smp_per_cpu_init(kernel_args *args, int32 cpu)
 
 
 void
+arch_smp_send_multicast_ici(CPUSet& cpuSet)
+{
+#if KDEBUG
+       if (are_interrupts_enabled())
+               panic("arch_smp_send_multicast_ici: called with interrupts 
enabled");
+#endif
+}
+
+
+void
 arch_smp_send_ici(int32 target_cpu)
 {
        panic("called arch_smp_send_ici!\n");

############################################################################

Revision:    hrev50439
Commit:      02283e080cbb1857cacde56e9c67b1ae90ab852a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=02283e080cbb
Author:      François Revol <revol@xxxxxxx>
Date:        Wed Jul 20 19:57:19 2016 UTC

M68K: drop the custom C arch_cpu_user_mem*() for the default impl

I didn't notice there was a C++ version that didn't require writing asm.

I'll have to write them anyway for speed someday.

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/arch/user_memory.h 
b/headers/private/kernel/arch/user_memory.h
index 79461e3..e4dd9f0 100644
--- a/headers/private/kernel/arch/user_memory.h
+++ b/headers/private/kernel/arch/user_memory.h
@@ -13,6 +13,8 @@
 
 #ifdef __x86_64__
 #      include <arch/generic/user_memory.h>
+#elif defined(__M68K__)
+#      include <arch/generic/user_memory.h>
 #else
 
 extern "C" {
diff --git a/src/system/kernel/arch/m68k/arch_cpu.cpp 
b/src/system/kernel/arch/m68k/arch_cpu.cpp
index 0eaeb49..8017cb9 100644
--- a/src/system/kernel/arch/m68k/arch_cpu.cpp
+++ b/src/system/kernel/arch/m68k/arch_cpu.cpp
@@ -171,95 +171,6 @@ arch_cpu_user_TLB_invalidate(void)
 }
 
 
-// TODO: all functions that use fault handlers need to be implemented
-// in assembly due to problems passing in label addresses in gcc4.
-status_t
-arch_cpu_user_memcpy(void *to, const void *from, size_t size,
-       addr_t *faultHandler)
-{
-       char *tmp = (char *)to;
-       char *s = (char *)from;
-       addr_t oldFaultHandler = *faultHandler;
-
-// TODO: This doesn't work correctly with gcc 4 anymore!
-       if (m68k_set_fault_handler(faultHandler, (addr_t)&&error))
-               goto error;
-
-       while (size--)
-               *tmp++ = *s++;
-
-       *faultHandler = oldFaultHandler;
-       return 0;
-
-error:
-       *faultHandler = oldFaultHandler;
-       return B_BAD_ADDRESS;
-}
-
-
-/**    \brief Copies at most (\a size - 1) characters from the string in \a 
from to
- *     the string in \a to, NULL-terminating the result.
- *
- *     \param to Pointer to the destination C-string.
- *     \param from Pointer to the source C-string.
- *     \param size Size in bytes of the string buffer pointed to by \a to.
- *
- *     \return strlen(\a from).
- */
-
-ssize_t
-arch_cpu_user_strlcpy(char *to, const char *from, size_t size, addr_t 
*faultHandler)
-{
-       int from_length = 0;
-       addr_t oldFaultHandler = *faultHandler;
-
-// TODO: This doesn't work correctly with gcc 4 anymore!
-       if (m68k_set_fault_handler(faultHandler, (addr_t)&&error))
-               goto error;
-
-       if (size > 0) {
-               to[--size] = '\0';
-               // copy
-               for ( ; size; size--, from_length++, to++, from++) {
-                       if ((*to = *from) == '\0')
-                               break;
-               }
-       }
-       // count any leftover from chars
-       while (*from++ != '\0')
-               from_length++;
-
-       *faultHandler = oldFaultHandler;
-       return from_length;
-
-error:
-       *faultHandler = oldFaultHandler;
-       return B_BAD_ADDRESS;
-}
-
-
-status_t
-arch_cpu_user_memset(void *s, char c, size_t count, addr_t *faultHandler)
-{
-       char *xs = (char *)s;
-       addr_t oldFaultHandler = *faultHandler;
-
-// TODO: This doesn't work correctly with gcc 4 anymore!
-       if (m68k_set_fault_handler(faultHandler, (addr_t)&&error))
-               goto error;
-
-       while (count--)
-               *xs++ = c;
-
-       *faultHandler = oldFaultHandler;
-       return 0;
-
-error:
-       *faultHandler = oldFaultHandler;
-       return B_BAD_ADDRESS;
-}
-
-
 status_t
 arch_cpu_shutdown(bool reboot)
 {


Other related posts:

  • » [haiku-commits] haiku: hrev50439 - src/system/kernel/arch/m68k headers/private/kernel/arch/m68k src/system/kernel/arch/m68k/paging src/system/kernel/platform/atari_m68k build/jam/repositories/HaikuPortsCross - revol