Repository navigation
m68kemu.library: native BOOPSI classes from m68k code (ReAction) - #1858
Open
terminills wants to merge 18 commits into
Open
terminills wants to merge 18 commits into
terminills wants to merge 18 commits into
Conversation
…RELOCS) On a non-68k host LoadSeg() relocates a hunk file to the addresses of its own segments and nothing can run it there; an emulator copies the segments into its own memory and needs to relocate them again. Record every 32-bit relocation the loader applies (hunk, offset, target, kind) in the seglist's segdata node, in the same allocation, and hand the table out through a new GetSegListInfo() tag. A failed allocation marks the table lost rather than handing out a partial one.
A program that opens an optional library (LZX opens arp.library) made the loader try LIBS68K:name with requesters enabled; with no such assign dos put up "Please insert volume LIBS68K" and the program waited on it forever. Turn requesters off for the three probes, as programs do.
…dArgs results Three things a 68k program needs on a 64-bit host and did not get: LoadHunks copied the segments dos had relocated to their host addresses into containment without relocating them again, so every absolute pointer pointed at host memory; a program without relocations was the only kind that ran. Apply the list dos now keeps with the seglist (GSLI_68KRELOCS), the exact inverse of what the loader did. A native BPTR is a 64-bit pointer and the thunks moved it through 32-bit registers; with memory above 4 GB a file handle lost its top half and the first Write() took dos down. Hand the m68k side an index into a per-context table instead (same native BPTR, same handle), in the generator's bptr class and the manual dos thunks; Close/UnLock/FreeArgs release the slot. ReadArgs() filled the m68k array with native pointers: strings, /N longs and /M string arrays the program could not reach. Copy them into one containment block per call and free it in FreeArgs().
…d OpenResource Each manual table's count was a literal; an added entry fell off the end and the dispatcher took the generated thunk instead. OpenResource was one of those generated thunks and returned a native resource base, a 64-bit pointer the 68k side then called through. A resource the emulator does not thunk now reads as absent, as a missing library does.
…he native version A fake base was four bytes; a program reading lib_Version through it read whatever followed. AROS's own startup compares dos.library's version with the one the program was built against and exits with RETURN_FAIL, so every AROS-built 68k command but Echo stopped after a few instructions. Lay out a full struct Library behind the jump table and copy the native library's version and revision into it.
…ed libraries The lists in the fake ExecBase are empty. SysInfo looks expansion.library up with FindName(&SysBase->LibList, ...) instead of opening it, assumes the result and calls FindConfigDev() through it, so it jumped through zero. Answer a lookup in LibList with the thunked base, setting it up on demand as OpenLibrary() does; devices and resources still read as absent.
What a classic system-friendly program needs beyond library calls, found by running SysInfo until it stopped asking for things: - the fake graphics, intuition and dos bases carry their full m68k layout synced from the native library; OpenScreen/CloseScreen keep IntuitionBase.ActiveScreen/FirstScreen and GfxBase.ActiView pointing at the program's screen (SysInfo takes &ActiveScreen->ViewPort unchecked) - the child process gets NP_Arguments, so ReadArgs on the transparent path sees the command line - Supervisor() returns with the caller's own SR; a user stack exists - the interrupt mask is lowered after reset; INTB_VERTB servers run as a level 3 autovector at 50 Hz from timer.device's E clock through a stub in low memory - CIA-A and CIA-B are modelled from the same clock (ports, timers, TOD): SysInfo times its tests with CIA-A's TOD - vectors 2-47 default to a stub that stops the program with a message; a MOVEC on a control register the core lacks (68040 TT/MMU) reads 0 and is skipped by advancing the frame's PC before it is written - PrintIText, DrawImage and DrawBorder translate their structures, byte-swapping plane words and coordinates; FindDisplayInfo hands out an opaque handle and GetDisplayInfoData copies DISP/DIMS/NAME field-wise - GetVPModeID answers INVALID_ID for an unknown ViewPort; CloseDevice on a request the emulator did not create is ignored - a program's screen opens in the Workbench's own mode and size (the VESA driver has one mode) and is painted once, since the driver pushes damaged regions only - diagnostics (per-call trace, exception trail, instruction ring, vector-table write trap) stay in the code behind ctx->trace_calls SysInfo 4.4 (Aminet util/moni) now opens its screen, draws its panel and waits for input on pc-x86_64 SMP in QEMU.
…t as a word Classic programs draw their frames and logos straight into sc_BitMap. The screen shadow had no planes, so those writes went nowhere and the panel came up as text on grey. Give the shadow real planes of the size the program asked for and, on every byte or word the CPU writes into them, recompose the touched pixels from all planes and put them on the native screen with WriteChunkyPixels(); OS drawing and plane drawing then compose the way they do on one set of bitplanes. The window RastPort's rp_BitMap points at the same planes. LoadRGB4() takes its count in D0.W; an assembler caller leaves the high word dirty, the thunk read all of it and the palette never loaded. Diagnostics come on with ENV:M68KEMU_TRACE instead of a rebuild.
…ions Gadgets: AddGList/AddGadget handed the program's m68k-layout gadget list straight to intuition. Each gadget is now copied into a native one with its Image/Border renders, IntuiText and PropInfo; a map lets RefreshGList, RemoveGList, ModifyProp, On/OffGadget find the copy and makes an IntuiMessage's IAddress name the program's own gadget. Selected state and prop pots are copied back after each message. SysInfo's buttons render as bevels and its gadget-up messages arrive with the right gadget. Heap: FreeMem() of a pointer the heap never handed out (SysInfo frees two garbage pointers while tearing down a device request it never opened) became the head of the free list, so every later allocation came from the vector table. Frees outside the heap, with a bad header, or of a block already free are now ignored. FPU: Moira implements no FPU instructions; they throw a C++ exception that never unwinds here and the emulator thread hung inside the instruction. Run the core as a 68LC040, where F-line instructions take the Line-F trap, and report a 68040 without FPU in AttnFlags. Diagnostics: M68KEMU_TRACE=msg starts the trace at the first IntuiMessage; with tracing on, a watchdog process reports the emulated CPU's position every two seconds.
… ExecBase Both read 0, and SysInfo divides its speed-test tick count by VBlankFrequency: pressing SPEED stopped it with a divide by zero. The emulator's vertical blank runs at 50 Hz; say so.
…y hunk, StackSwap m68k libraries without a native replacement belong in LIBS68K:; when that assign is not set the loader uses SYS:Libs68k/. LIBS:m68k/ and LIBS: are still searched, but only a hunk file is taken from any of them: LIBS: also holds the native libraries, which were read and rejected one by one. The heap allocates top down, so a library's later hunks sit below its first one and the Resident scan upward from the first hunk missed a RomTag kept in the data hunk (AKCC's akccplus.library). Record the span each load occupies and scan all of it. exec StackSwap() exchanges the program's stack pointer with stk_Pointer. The loader's informational lines move behind M68KEMU_TRACE.
The emulator includes the protos of log.resource, diskfont, commodities, workbench and other libraries outside the kernel set; in a fresh build tree it could be compiled before they were generated and failed on proto/log.h.
…uiet failures Libraries for 68k programs: - mathffp, mathtrans, mathieeesingbas/trans, mathieeedoubbas/trans are computed natively (FFP converted, doubles in D0/D1), with the condition codes the callers branch on (Cmp, Tst) set after the call. - workbench.library: App* registration succeeds without AppMessages yet, OpenWorkbenchObjectA runs natively. - commodities.library: CxBroker and CreateCxObj translate their m68k arguments; the generated thunks passed the program's NewBroker as is and the native broker code faulted in strcmp. - intuition menus: SetMenuStrip/ResetMenuStrip/ClearMenuStrip translate the program's Menu/MenuItem strip, ItemAddress walks the program's own strip, MENUPICK copies Flags and NextSelect back; CloseWindow drops the strip. - exec SuperState/UserState (the program already runs in supervisor mode) and StackSwap. 68k libraries from LIBS68K: run their init function (as a tail call into 68k code when OpenLibrary returns), apply their InitStruct data, and read WORD-offset function tables; AKCC's akccplus.library works now. The emulator's process gets a CLI when started from a Shell, so programs checking pr_CLI see one. A failing program is reported in one line to the system log (LogDump), not as a register and instruction dump painted over the screen by the debug console; the full dump stays behind M68KEMU_TRACE.
…maphores, window shadow Native objects the program gets back (VisualInfo, CxObj, BOOPSI objects, devices' units) are pointers that do not fit in D0: they go out as handles from the BPTR handle table and are decoded on the way in, for generated and manual thunks alike. GadTools menus: CreateMenusA builds the strip natively and hands the program an m68k mirror, with the UserData slot after each Menu/MenuItem; LayoutMenus(Items)A lay out the native strip and copy the geometry back; FreeMenus frees both; SetMenuStrip attaches the native strip of a GadTools menu instead of translating it again. GT_GetIMsg/GT_ReplyIMsg go through GetMsg's message translation, so messages are not leaked. OpenWindowTagList translates every pointer-valued WA_ tag by type (PubScreen, CustomScreen, Gadgets, Checkmark, AmigaKey, Zoom, titles) and follows TAG_MORE/TAG_SKIP; WA_PubScreen was passed as an m68k address and the window never opened. The generic tag-list conversion resolves shadows and handles first and no longer treats small values or the IDCMP/flags tags as pointers. Device I/O: an m68k IORequest gets a native twin (timerequest, IOAudio or IOStdReq) kept in step around OpenDevice, CloseDevice, DoIO, SendIO, CheckIO, WaitIO and AbortIO; io_Device is an m68k device base whose BeginIO/AbortIO and timer.device functions are thunks; GetMsg hands back the program's own request when a device replies. A reply port the program built in its own memory gets a native twin on its signal bit. Devices whose request layout is not translated fail to open instead of receiving an m68k structure. AbortIO is passed on only for a request in flight. The rest of the semaphore family matches Init/Obtain/ReleaseSemaphore (the program is one emulated task): attempts succeed, list calls do nothing, AddSemaphore/FindSemaphore/RemSemaphore keep a name table. The Window shadow gains WLayer (and the RastPort's rp_Layer) as a layer shadow with its RastPort and bounds, the border widths and the GZZ size: a program locking its window's layer called LockLayer(NULL). QEMU, Aminet batch: AmigaEyes opens its window, Ameko and 7-Zip get past their libraries and devices, AKCC and SysInfo unchanged; no 68k program takes the emulator down.
Programs report their errors through EasyRequest, and the call stopped them instead. The arguments of the text and gadget formats are one m68k datastream; it is repacked for the native call, and the IDCMP flags are copied in and out. The intuition table also had dead second entries for -432 and -438 (lookup takes the first); removed with their no-op thunks.
Every LockPubScreen built a new Screen shadow and none was ever freed, so a program that locks the screen repeatedly filled the shadow table. A structure that already has a shadow of its type now gets that one back, brought up to date. A Screen shadow from the field tables had no shadows for its embedded ViewPort and RastPort and a NULL ViewPort.ColorMap (pointer fields without a layout are written as NULL): ObtainBestPen() on it faulted in graphics.library. Both screen paths now register the ViewPort and the RastPort and give the ColorMap a shadow of the native one.
Insert, AddHead, AddTail, Remove, RemHead, RemTail, Enqueue and FindName ran the native functions on lists in m68k memory, writing 64-bit little-endian links into 32-bit big-endian nodes. They now link m68k lists in m68k layout; a list that is a shadow of a native one still goes to the native function. The choice follows the list, since a program's nodes may be shadows themselves.
OpenLibrary of a .class, .gadget or .image opens the native class library behind an m68k base: GetClass, the label node functions of chooser, clicktab, radiobutton, speedbar and listbrowser, and RethinkLayout/PAGE_GetClass of layout.gadget. NewObjectA, DisposeObject, SetAttrsA, GetAttr, SetGadgetAttrsA and DoGadgetMethodA work on native objects. The program gets an m68k stand-in for each: an _Object header whose class is an m68k IClass, and a Gadget-sized body kept in step with the native gadget. The class's dispatcher hook points at a vector of a pseudo library, so amiga.lib DoMethod() runs the method on the native object: OM_SET, OM_GET, OM_DISPOSE and the window.class methods (WM_OPEN returns the window's shadow, WM_HANDLEINPUT writes the code back). Tags whose data is a structure in the program's layout are translated: WINDOW_NewMenu, LISTBROWSER_ColumnInfo, GA_TextAttr, label string arrays, and label lists - the program links the m68k stand-ins of the nodes into its own list, and a native copy is built when the list is passed. ~0 stays ~0. Read-back values that point at native data (STRINGA_TextVal, SPACE_AreaBox) are copied into memory of the object. DrawImage draws a BOOPSI image natively. The shadow table grows to 1024 entries and the library table to 64. QEMU: the ClassAct 2 68k example binaries (string, fuelgauge, glyph, page, clicktab, speedbar, SpeedTest) open their windows on the native classes; AmiLines opens its board.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #1855, #1856 and #1857 (included; review the last commit).
68k programs can use the native ReAction classes. OpenLibrary of a .class/.gadget/.image opens the native class library behind an m68k base (GetClass, the label node functions of chooser, clicktab, radiobutton, speedbar and listbrowser, RethinkLayout/PAGE_GetClass). NewObjectA, DisposeObject, SetAttrsA, GetAttr, SetGadgetAttrsA and DoGadgetMethodA work on native objects through m68k stand-ins whose class dispatcher routes amiga.lib DoMethod() back to the native object (OM_SET/OM_GET/OM_DISPOSE and the window.class methods). Tag data in the program's layout is translated (WINDOW_NewMenu, LISTBROWSER_ColumnInfo, GA_TextAttr, label arrays and label lists), and values read back that point at native data are copied into the program's memory.
QEMU, together with the ReAction class pull requests #1851-#1854: AmiLines 3.00 (Aminet, 68k) opens its ReAction window and plays; the ClassAct 2 68k example programs open their windows on the native classes.