LKOS2 — A Linux Kernel for OS/2 (project announcement, early alpha)

Started by phaelonimaire, July 13, 2026, 05:24:45 AM

Previous topic - Next topic

Dave Yeo

Quote from: phaelonimaire on September 09, 2026, 03:24:32 AM
Quote from: Dave Yeo on September 09, 2026, 01:32:18 AM

JFS is a good choice, supports EA's, can be mounted case insensitive, which happens automatically when mounting an OS/2 JFS volume here with Mint. Has (on OS/2) unicode.sys to translate code pages to UTF8 and back. I'm running my Mint install on Linux JFS and have my OS/2 JFS volumes mounted, works fine.

Have you had problems mounting OS/2/eCS/ArcaOS-created JFS in Linux?  The latest bootable JFS I have is from eCS 2.1, and I had to patch the Linux JFS module to get it to load.  Something about garbage in the superblock pad field.  I'm running Linux 6.8.0 in Xubuntu 24.04.  Whatever kernel I eventually distribute will have this patch, but it would be nice to know if it's a real problem or just my garbage.

Further investigation shows that PMFormat is the cause of the bad super block padding and stray weird character in the Linux Volume name. format.exe x: /fs:jfs produces a JFS volume that easily mounts on linux (ignoring the permission problem).
Seems the ArcaOS installer and likely the eCS installer use the same DLL that PMFormat uses.
Only tested PMFormat with the defaults. I know Linux JFS doesn't support different block sizes. Don't know about whether sparse files are compatible though I'd guess so. Same with changing the journal size.



Martin Iturbide

Quote from: phaelonimaire on September 27, 2026, 12:21:17 AM
Warpstock update: I'll be there.

That's awesome. I hope to see you there. I'm still on the fundrasing to go to Warpstock this year and document the event.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Leonardo

Very happy to hear about this effort. Every work should be welcome. I was thinking on how this project could benefit from old work on the same goal, like os2free for example https://github.com/osfree-project

Have you looked into it?


phaelonimaire

Quote from: Leonardo on October 01, 2026, 03:56:23 PM
Very happy to hear about this effort. Every work should be welcome. I was thinking on how this project could benefit from old work on the same goal, like os2free for example https://github.com/osfree-project

Have you looked into it?

I have.  I've excitedly followed your project for years.  My original thought was to actually start my build with it, but I hadn't yet decided on the shape of what I was building. 

I've used your project for reference from time to time, but didn't want to pull in anything from it out of respect for your work.  I genuinely love the concept.  The decision to use the Linux kernel in mine was purely about drivers and familiarity than anything else. 


Leonardo

I wouldn't take credit for that job. It isn't mine, but I have always been fascinated with the OS/2 PPC and it's architecture and in a very curious turn of events; today I came across this site https://github.com/ajfa/os2-ppc-qemu. It has all that's needed to finally be able to have QEMU working with the power series hardware that was the only hardware able to boot OS/2 for PPC. With the help of claude I was able to compile QEMU on my mac and now I'm running OS/2 for PPC in my macos machine. Only after 30 years. It's never too late  ;D

Now I'l play with it for a while

Thanks to whoever did this


Leonardo

Quote from: phaelonimaire on October 02, 2026, 04:52:10 AM
Quote from: Leonardo on October 01, 2026, 03:56:23 PMVery happy to hear about this effort. Every work should be welcome. I was thinking on how this project could benefit from old work on the same goal, like os2free for example https://github.com/osfree-project

Have you looked into it?

I have.  I've excitedly followed your project for years.  My original thought was to actually start my build with it, but I hadn't yet decided on the shape of what I was building. 

I've used your project for reference from time to time, but didn't want to pull in anything from it out of respect for your work.  I genuinely love the concept.  The decision to use the Linux kernel in mine was purely about drivers and familiarity than anything else. 



Now I did started a new pet project and going over your posts I see a very good oportunity to create a knowledge base of the OS/2 ABI. In particular your findings on the gaps and differences of OS/2 APIs, return codes that do not match the offitial docs, behaviour that has never been explain. This is a gold mine to the community. Maybe you could instruct the AI to create the documentation or give access to other people to the MDs, specs etc, so that a document can be created else where (so you don't use your tokens on that)

Just an idea.
Thanks for your work

phaelonimaire

Quote from: Leonardo on October 21, 2026, 07:21:46 PMNow I did started a new pet project and going over your posts I see a very good oportunity to create a knowledge base of the OS/2 ABI. In particular your findings on the gaps and differences of OS/2 APIs, return codes that do not match the offitial docs, behaviour that has never been explain. This is a gold mine to the community. Maybe you could instruct the AI to create the documentation or give access to other people to the MDs, specs etc, so that a document can be created else where (so you don't use your tokens on that)

Just an idea.
Thanks for your work


This is in part where my claude-os2-toolkit project comes in. https://github.com/phaelonimaire/claude-os2-toolkit.  It helps to some degree, but it doesn't provide a unified source of knowledge.  I'm working updating it at the moment, as a lot has changed.  I'm hoping we can get together as a community and figure out how to arrange all of this into something everyone can use (the knowledge) without giving a bunch of AI-hallucinated half-truths.  I've built test programs to validate most of the families of DOSCALL1.DLL (recorded against WSeB CP2) already and will eventually have a full suite. See my next post.

phaelonimaire

TL;DR

  • IBM's own CMD.EXE runs again, on a restructured OS/2 layer: banner, prompt, TYPE, SET, COPY, redirection and batch files.
  • Linux stays the kernel. os2server and liblkkrnl, the library that holds the OS/2 API implementations, are now one OS2KRNL-shaped layer between OS/2 programs and Linux, instead of a copy of the services inside every OS/2 process.
  • Every process is native 64-bit. The lower 4 GB of its address space (address space, not RAM) is OS/2's; 64-bit test programs, ELF files that call liblkkrnl's Dos* functions and never Linux, run above it with their own C library.
  • 16-bit and 32-bit programs reach the layer through LKCALL1.DLL, our replacement for DOSCALL1.DLL.
  • Screen groups and the session manager are built in IBM's shape, on one framebuffer, with keyboard switching.
  • The internal DosISem* semaphores that stopped most PM programs and the Workplace Shell in September are now built properly.
  • Our own NE/LX test drivers load from CONFIG.SYS on the new layer; IBM's drivers are next.
  • PM does not run on LKOS2 yet. A test program loads IBM's PMMERGE.DLL and gets part way through its initialisation.
  • New part of the project: Pane, an early, in-progress replacement for IBM's PM DLLs, developed on real OS/2. It does not replace IBM's PM today; see the note at the end.
  • I will be at WarpStock, and I hope to have PM booting again by then.

In September I described LKOS2 booting PM, running CMD.EXE full screen and loading real drivers from CONFIG.SYS. Shortly after that post I took most of it apart. For most of October no 16-bit or 32-bit program ran on the code I was working on, which is why I held this update back until they did. As of this weekend CMD.EXE runs again, on a layer shaped the way OS2KRNL is. This post explains what changed and why.

The 64-bit work, the drivers and the C library all went on at the same time, which is why there is so much in one post.

Why the OS/2 layer was restructured

In September each OS/2 process carried its own copy of the OS/2 services, and os2server answered by message for anything that had to be shared. That held up for single calls. It did not hold up for the work in September's "What's next" list. Session switching, screen groups and the internal semaphore family PM waits on are all kernel state in OS/2, shared by every process and held in one place. Building them as messages between processes meant building each one twice: once as a workaround, and again when it moved to where it belongs.

So the layer is now shaped the way OS2KRNL is. Linux remains the kernel: it schedules, pages and does the real device I/O. os2server and liblkkrnl are the OS2KRNL-shaped layer between OS/2 programs and Linux. Their code and data sit in one shared region that every OS/2 process attaches, and a program enters it through a single entry, the way an OS/2 program enters OS2KRNL. It is all still ordinary userspace on Linux's stable interfaces, with no custom Linux kernel module.

The API was not rewritten. The DOSCALLS implementations from the old structure were carried into the new layer one family of calls at a time (memory, processes and threads, modules, files and extended attributes, semaphores, queues, pipes, timers, code pages, system information, sessions, the screen and the keyboard), each checked against real OS/2 4.5's answers. One working rule was added: every design is written down and agreed before any code is built.

The 64-bit side

Every LKOS2 process is a native 64-bit Linux process, split in two at 4 GB.

These are virtual addresses, not RAM. The split is in each process's address space, which is 128 TB wide on a 64-bit Linux, and no memory is set aside for it. Linux decides where in physical memory each page lives, and an OS/2 program's pages can be anywhere in RAM, above 4 GB included. The lower 4 GB is reserved because that is all a 16-bit or 32-bit program can address, not because of how much memory the machine has.

Below 4 GB is OS/2's, laid out as OS/2's own arenas: private and shared up to 512 MB, the high arenas up to VIRTUALADDRESSLIMIT=, and drivers' segments at the top. Only OS/2's allocators place anything there, so a 16-bit or 32-bit program is never handed an address it cannot hold. Above 4 GB are 64-bit programs, their DLLs, and liblkkrnl, which is mapped at the same address in every process. A 64-bit program calls liblkkrnl's entry points directly, through a short stub, with no system call or mode switch. 16-bit and 32-bit programs go through LKCALL1.DLL, which sits low where they can call it, converts their arguments and makes the same call. There is one implementation of each call, and every program width reaches it. For now, 64-bit programs are used only for testing; the programs you run are your existing OS/2 ones.

How 16-bit code reaches 64-bit code. It is often said that 64-bit systems cannot run 16-bit programs. What a 64-bit x86 CPU gives up is virtual-8086 mode, which is how DOS programs run, and that is why LKOS2 runs as PROTECTONLY=YES. OS/2's 16-bit programs are protected-mode code, and in 64-bit mode the CPU still runs 16-bit and 32-bit protected-mode code segments side by side with 64-bit ones. Linux lets a process define such segments in its own descriptor table, and an OS/2 program's segments are exactly that. Moving between them is a far jump or far return from one code segment to another. LKCALL1's entry stub saves the caller's registers on the caller's own stack and far-returns into Linux's 64-bit code segment. The 64-bit side switches to a stack above 4 GB, converts the arguments and calls liblkkrnl. It then returns into the caller's 16-bit or 32-bit segment, and the stub returns with the same retf N IBM's DOSCALL1 uses, so the caller's stack ends up exactly as on OS/2. No Linux system call is involved. The same path runs the other way when liblkkrnl has to call back into a program, for example to run its exception handler.

64-bit programs are ELF, but they are not Linux programs. A 64-bit LKOS2 program is an ordinary ELF file, built with stock GCC and the LKOS2 SDK. Its imports name the Dos functions in liblkkrnl, the way an LX program's imports name DOSCALLS ordinals, and a small header record (an ELF note) gives its interface version, application type and stack size. liblkkrnl's loader reads it, binds the imports and starts the program as it starts any OS/2 program. The program makes no Linux system calls: its C library runs entirely on Dos calls, and the SDK build checks that the library contains no system-call instruction at all. 64-bit programs are designed to call 16-bit and 32-bit APIs with the same compile-time thunks OS/2 already uses; that part is not built yet.

Screen groups and session management

In September, sessions and screen groups were the work that the old structure resisted most. They are now built once in the OS/2 layer, in IBM's structure, as one family with VIO, the keyboard and the mouse.

  • Screen group 0 exists from boot, set up by os2server's boot sequence, which does SYSINIT's job. PROTSHELL joins it, as on OS/2.
  • Each screen group has its own video state in IBM's layout, and a switch saves one group and restores the next. A background program writing straight to the physical buffer is blocked until its group comes forward, as on OS/2.
  • There is one framebuffer, shaped like the Linux console's. Our own BVS draws full-screen text sessions straight into it, in place of September's emulated VGA card and IBM's BVHVGA running on it. PM's video will come from our own GRADD driver, drawing into the same framebuffer, just as we built our own BVS for text. The screen-group switch decides who owns the framebuffer. The VIDEOPMI shim from September is gone: VIDEOPMI is no longer part of how PM gets drawn.
  • The session manager serves the DosStartSession family and the undocumented DosSM/DosSG interface PMSHELL uses. Until PM runs, PM's side of it is tested with stand-ins.
  • Switching works from the keyboard, and input follows the foreground: line input, Ctrl+C and Ctrl+Break, and the mouse.
  • Windowed consoles and the Window List work as on OS/2 and arrive with PM: a VIO window is drawn by IBM's own BVHWNDW, which BVS hands the calls to as OS/2's BVS does, and Ctrl+Esc brings up IBM's own Window List. The layer underneath is built.

How it is tested: for each family of calls, a matrix of every return IBM documents, plus any undocumented answer real OS/2 gives, is agreed first. A test program is made correct on real OS/2, its answers are baked in, and one expectation is broken on purpose to show it can fail. It runs straight through, under stress across threads and processes, and as several copies at once, then unchanged against LKOS2. Screen work is also checked by looking at the screen at every transition.

16-bit and 32-bit programs: LKCALL1.DLL

LKCALL1.DLL is our DOSCALL1.DLL. Its data segments follow IBM's layout, and its code turns each 16-bit or 32-bit call into liblkkrnl's one 64-bit form of that call. Since the middle of October:

  • The program loader moved into liblkkrnl. A 16-bit NE or 32-bit LX program is read, placed, given its selectors and fixed up there.
  • The families were connected one at a time: info segments, date and time, resources, semaphores and timers, queues and named pipes, the keyboard and mouse, VIO, the session manager and switching, signals, messages, and extended attributes, each checked against its real-OS/2 capture.
  • Signals were rebuilt properly, with a new suite measured on a real OS/2 SMP machine.
  • The thunk helpers, the 32-to-16 and 16-to-32 universal thunks among them, were rebuilt to the contract read from DOSCALL1's code.
  • Exception handling for 16/32-bit programs: a fault builds IBM's exception frame and walks the program's own handler chain.

The semaphores that blocked PM in September. The internal DosISem* calls, which stopped most PM programs and the Workplace Shell in September, are now built properly and give the same answers as real OS/2. PM itself has not run on the new layer yet, so this is the blocker built, not yet shown to be cleared.

The result: IBM's unmodified CMD.EXE prints its banner, prompt and messages, and runs TYPE, SET, redirection, COPY with extended attributes, and batch files. With a session manager running, START opens a new full-screen session; for now a test program stands in for PMSHELL there, and a plain PROTSHELL=CMD.EXE boot answers SYS1059. A test program also loads IBM's PMMERGE.DLL and gets part way through its initialisation; PMSHELL itself has not run yet.

A C library for 64-bit programs

64-bit programs have a C library: a static port of mlibc, delivered as an SDK. The port is new since September. A plain hello.c built with stock GCC runs on LKOS2, and the library has threads (pthreads and IBM's _beginthread), signals, text mode, OS/2's errno and _doserrno, temporary files the OS/2 way, and the process's orderly end. Building the thread support exposed a per-process thread limit in liblkkrnl, which has been replaced by IBM's model: one system-wide pool sized by THREADS=.

Where IBM's documentation does not settle how the C runtime should behave, Bitwise Works' LIBC Next is the reference I check first. It has already answered these questions for OS/2.

LKCMD, a 64-bit command prompt

LKCMD is a 64-bit command prompt specified by IBM's CMD.EXE: the Command Reference first, and CMD.EXE's binary where the reference is vague. It is our own code and our own messages, not a copy of CMD.EXE and not based on 4OS2. CMD.EXE itself keeps running unchanged, as above. LKCMD exists to be a real 64-bit program exercising the OS/2 layer.

It now has the everyday built-ins, redirection on any handle, command chains and groups, pipes, batch files (CALL, GOTO, SHIFT, SETLOCAL), and IF and FOR. Every one of those behaviours was captured on real CMD.EXE first. Building it turned up a run of defects in liblkkrnl, fixed at their source: drive-relative searches, hidden and system attributes, DosPutMessage's line breaking, .. above the root, and a race in its shared heap that could zero live memory under load.

Drivers, back on the new layer

The September driver host was built on the old structure and did not survive the move. It has been rebuilt on the new layer, modelled on OS2KRNL's own contexts rather than on a separate host:

  • liblkkrnl loads NE and LX driver images, gives them selectors and runs BASEDEV= and DEVICE= INIT in OS/2's order.
  • The DevHlp router, the device chain, AttachDD, IOCtls, and ProcBlock/ProcRun sleep and wakeup.
  • RESMGR$ and OEMHLP$, answering from what Linux has detected: PCI configuration space, ACPI, USB, legacy PnP devices and ROMs. IBM's binary layouts are kept; the limits that encoded 1990s PC hardware, such as IRQ below 16 and ISA DMA, are not.

So far the drivers loaded are our own test drivers. A test driver built with IBM's RMCALLS.LIB gives the same twelve answers on real OS/2 and on LKOS2. IBM's own drivers are next, starting with POINTDD.SYS.

The 64-bit driver format I asked for comments on in September has been simplified to a single shape. It is still a design, and comments are still welcome.

Where things stand

  • CMD.EXE runs. PM and the Workplace Shell do not yet; PMMERGE's initialisation is the current work.
  • 64-bit programs run with a C library, and LKCMD runs on it.
  • Drivers load from CONFIG.SYS on the new layer, so far our own test drivers; IBM's drivers and the real disk chain (OS2DASD, the IFS drivers) are still ahead.
  • Networking, writable HPFS/JFS and the VM image have not moved.

What's next

  • Exception delivery across threads, the last piece of 16/32-bit exception handling.
  • PMMERGE's initialisation, then PMSHELL.
  • Bringing the 16/32-bit work and the drivers together, so everything runs on one layer again.

WarpStock

I will be attending WarpStock. If anyone wants to discuss LKOS2, or see it in whatever shape it is in by then, just ask. I hope to have it booting PM again by that time, on top of everything described above.

A note on Pane

Pane is a new part of the project: a replacement for IBM's PM DLLs (PMMERGE and PMGPI), with the same module names, ordinals and message behaviour, which will come into LKOS2 later. It is early work, developed and tested on real OS/2, and it does not replace IBM's PM today; LKOS2's PM work above is on IBM's own PM. Much of PM is not built in it yet, and every entry that is not built returns its documented failure value. So far IBM's own PMSHELL boots on it and paints the desktop, a test program's window comes out pixel-identical to IBM's, the Window List and full-screen session switching work, and standard frames with menus work. A companion project, wp, is doing the same for the Workplace Shell's PMWP.DLL, and is earlier still.



LKOS2 runs your existing, licensed OS/2 installation. The binaries are IBM's own, unmodified. Linux is the kernel underneath; the project supplies the OS2KRNL-shaped layer between it and your programs, not the operating system on top.

Martin Iturbide

Hello phaelonimaire

QuoteIBM's own drivers are next, starting with POINTDD.SYS.

Just in case I created with AI this POINTDD driver testing around.
https://github.com/OS2World/OS2-DRV-Replacement-Experiment/tree/main/POINTDD
Maybe it can help you in something.

Please make Ctrl+C and Ctrl+V to work on LKCMD  ;D  ;D  ;D

See you at Warsptock, I'm looking forward for your presentation.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

jmase

Wow,
having read through the years all about how to run OS/2 apps on other systems and the work to be done to be able to support 16 and 32 bit apps on 64bit systems...
What you have started is great!

I like that you plan ahead to replace OS/2 components that can in the future be a foundation for "Warp 5", OS/2-64, whatever you want to call it :) 


A few questions/thoughts,

Why support OS/2 drivers? I understand that some drivers must be there, but do you plan for allowing all OS/2 drivers to run?

What I think about drivers, 64bit drivers should be pure Linux drivers, a thin layer for converting the way an OS/2 app (16/32-bit) talks to drivers and for 64bit OS/2 apps they should talk to Linux drivers as natively as possible.
Reason for this is to reuse Linux kernel and drivers as much as possible, there should be no need to write drivers and/or have conversion code for each driver.

I look forward to be able to participate in designing a 64bit and opensource version of the OS/2 API.

Dave Yeo

Sounds like things are coming along well, good work.
Couple of questions.
How are drive letters going to work, along with DOS file attributes and the 2TB disk limit?
16 bit code, you talk like it will have a 4GB address space. Currently, the design of the i386 limits it to 1GB of address space.
Private vs shared memory, how is that implemented and is it possible for each process to have its own 4GB (limited by virtualaddresslimit). And is there a need for virtualaddresslimit?
ELF, will it use DLLs or shared libraries. Be interesting to know how IBM did it on the PowerPC version of OS/2
All I can think of right now, thanks

phaelonimaire

I didn't explain that very well. There's also a native 64-bit driver format, and it's already designed and documented, though not built yet. It works much as you suggest. A driver is a 64-bit ELF module that declares which Linux kernel modules it needs. LKOS2 loads those before the driver starts and reference-counts the ones drivers share, much like an EXE's DLL imports. They're stock distro-built modules; LKOS2 never ships or builds a kernel module of its own. The driver talks to LKOS2 through DevHlp64, a deliberately thin set of wrappers over the Linux kernel interface. That's the 64-bit
 counterpart to OS/2's DevHlp.

So, to answer directly: no, the goal isn't for every OS/2 driver to run, and nobody should be using IBM1S506.ADD to drive their IDE disks. Linux owns the real hardware. Drivers matter for a different reason. When you're building support for something with a lot of unknowns, it works best to start close to the original shape and load the same components the original would. Drivers are also the natural cleavage point for adapting a system. At some point an OS/2 call has to become a Linux call, and the driver model is a well-defined place to put that boundary.

The current work has three goals:

  • Validate my loading and execution mechanisms against real drivers whose behaviour  can compare back to real OS/2
  • Keep compatibility with existing applications that depend on a driver or IFS backend, such as Samba, NetDrive and SIO's VModem (I'm weird)
  • Provide a modular interface between LKOS2 and Linux, so nobody has to recompile the whole project to try a different adaptation approach

In other words, I'm using the existing driver model as the way to write and manage the bridges. For example, my virtual INET$ shim doesn't have to be compiled into LKOS2. It can be a driver that someone chooses to load, and they can run IBM's drivers instead if they'd rather.

As for designing a 64-bit, open-source OS/2 API: I'd welcome that. The 64-bit driver format is still a draft, so this is a good time for input.


A word on the name, while it's early
I'm not sold on LKOS2 as an open-source OS/2 name. It describes a kernel swap, not an environment. I'd like to stay away from anything Paramount Pictures might have a claim to. Putting "Linux" in the name might also set the expectation that this is an OS/2-shaped Linux distro, which it isn't. LKOS2 is a working name for now; the real name is still open.  I wouldn't put too much effort into a name until I have produced something worthy of people's time and effort.  There is a logo of sorts already, but it's my own weird humor poking through.


Leonardo

Hi

Since LKOS2 is already making significant progress toward 64-bit OS/2, I believe it would be beneficial for other projects to converge on a common 64-bit ABI, allowing applications to run on any implementation without recompilation.

I'd suggest three guiding principles:

1. Kernel-independent public ABI

The OS/2 64-bit ABI should remain independent of Linux-specific implementation details. Public structures, calling conventions, memory semantics, threading, exceptions, and other observable behaviors should not require a particular underlying kernel.

2. Documented and verifiable specification

The ABI should be explicitly documented, including data types, structure layouts, calling conventions, executable format, dynamic linking, exception handling, and API semantics.

Compatibility should be based on a stable specification rather than requiring other implementations to reproduce liblkkrnl's internal behavior.

3. Independent implementation and conformance testing

Ideally, both projects should eventually execute the same 64-bit OS/2 test binaries without modification. A small shared conformance suite could help identify incompatibilities early, particularly around memory management, threading, exceptions, and dynamic loading.

My intention is not to influence LKOS2's internal architecture or slow down its development. Quite the opposite: LKOS2 could lead the definition of the OS/2 64-bit ABI that other efforts could adopt too. You lead the way hopefully in an independent portable way.

 

phaelonimaire

Thanks! Good questions, in order:

Drive letters, attributes and the 2 TB limit

For now, a drive letter is just a host directory: C: is a directory, D: is another, and a symlink works too. The plan is for the system to mount the boot volume itself and assign the rest from configuration, but I haven't implemented LVM's drive-letter assignment yet.

How attributes are stored depends on what's behind the drive. Drives served by my VFS layer store DOS attributes in the Unix permission bits, much the way Samba does it, and keep EAs in a per-drive database beside the files. Once IFS hosting lands, drives served by a real IFS like HPFS or IBM's JFS.IFS will keep their attributes and EAs exactly as the filesystem always has.

The 2 TB limit remains for legacy applications. It comes from 32-bit sector numbers in the storage stack (the IORB, the driver request packet, the MBR), which cap a volume at 2 TiB. Legacy applications also have their own, lower limits: 32-bit file offsets, and code that multiplies DosQueryFSInfo's fields into a 32-bit byte count. The I/O may eventually reach a Linux block device, but the API those applications use is still IBM's. I've extended bit widths in places, and the large-file APIs IBM added in Warp 4.5 are there, but that doesn't help existing 32-bit applications, because their limits are baked into the code they were compiled with.

16-bit code and address space

You're right that x86 segmentation gives a 16-bit task 1 GB of selector space across the GDT and LDT. OS/2 tiles only the LDT onto linear memory (8192 selectors × 64 KB), so 16-bit code reaches the 512 MB compatibility region, and LKOS2 does the same. IBM's older documentation gives the classic 448 MB for applications: 512 MB minus at least 64 MB reserved for shared memory. As on Warp Server SMP and later, 32-bit code can allocate above 512 MB with OBJ_ANY, up to VIRTUALADDRESSLIMIT. High memory isn't tiled, so 16-bit code can't reach it.

Private vs shared memory, and VIRTUALADDRESSLIMIT

The layout follows OS/2's. Each process has a private arena of its own, and shared objects sit at the same address in every process that uses them, as one copy, not a copy per process. Above 512 MB there's a high private arena growing up and a high shared arena growing down from the limit, as IBM describes it. Under OS/2, a 32-bit process doesn't get its own 4 GB either: user space ends at VIRTUALADDRESSLIMIT (default 2 GB, at most 3 GB, and 512 MB on kernels without high-memory support), and the system region above that is shared.

VIRTUALADDRESSLIMIT is a 32-bit application limitation. I've kept the ability to configure it in case some application needs the number smaller, and LKOS2 honours it the way IBM's kernel does: it's what QSV_VIRTUALADDRESSLIMIT reports, it sets the top of the high arenas, and it feeds the maximum process count. 64-bit programs aren't bound by it.

ELF: DLLs or shared libraries?

DLLs. I should be clearer about this, because "ELF format" on a Linux kernel suggests a set of expectations that don't apply here. ELF is the container, not the semantics. I chose it because it's well understood and many compilers already support it, not to bring the intricacies of ELF into OS/2. One of the complicating factors with ELF, and with Linux's abilities generally, is deciding what to keep, what to adapt, and what just doesn't fit in OS/2 at all.

Two OS/2 mechanisms in particular don't exist in standard ELF in the same shape:
 
  • The ordinal map. A 64-bit module exports by ordinal, with an optional name, under a module name, and its imports are bound to a specific named module. By default, ELF resolves undefined symbols by name against a global lookup scope, and nothing in an import names the library it must come from. Linux's dynamic linker isn't used at all.
  • Shared objects. The name collides, so to be precise: in ELF, a "shared object" is a library. In OS/2, a shared data object is memory that every process using the module sees as one copy, at the same address. A lot of OS/2 depends on that. PMMERGE manages device contexts from a shared object, the session manager's globals and the BVS global table live in DOSCALL1's shared objects, and each screen group's BVS control block is a named shared segment. Standard ELF has no equivalent, so LKOS2 provides its own.

So far my approach has been similar to AMD's with AMD64: extend the OS/2 model to 64 bits, preserving its methodology and general shape, instead of adopting Linux's environment wholesale. If there's something I'm missing, or someone has a different opinion on what this shape should be, I'm happy to listen.

As for the PowerPC edition: IBM wasn't trying to coexist with i386 OS/2 there, but it turns out they reached much the same answer. IBM's OS/2 Application Binary Interface for PowerPC (32-bit) uses ELF as the container, with OS/2 semantics layered on top. Every OS/2 load module carries import and export tables. An import names the module that provides it and can go by ordinal, which takes precedence over name, and exports are kept sorted by ordinal. Shared data is a segment flag, and a DLL's ordinary read/write data gets a per-process copy at the same virtual address in every process. That's close to where I ended up, which is reassuring. The osFree project has a copy of the ABI document if anyone wants to dig in.