purge touch-friendly Inferno on a 2017 phone Project Goals

•Replicate Hellaphone (video, source) / run Inferno on moto e4 •Create an Inferno multitouch driver for moto e4 •Add a touchscreen API to Inferno •Next: Create moto e4 Purge ROM

2 Inferno (homepage) •An open source •Focuses: • Environment portability • Application portability • Minimal memory footprint • Standard communication protocol between any Inferno machine

3 Universal Inferno Platform (UIP)

Application Application Application Inferno x86 FreeBSD Linux Windows MIPS super- router desktop laptop router computer

Hosted Native Ports

Diagram inspired by Inferno: An Overview (PDF) 4 Inferno: Details

Files Tetris Coffee Shell Clock Browser ns date echo sleep sh Window Manager Applications Shell Window Manager Non-Window Manager Applications

The Dis Virtual Machine

Libraries (Math, Tk, …) Virtual Device Drivers System Calls (ssl, …) (emu/) Inferno Kernel (os/) Host OS Interface Native Drivers Host OS (Linux, Windows, FreeBSD) Native Port (x86, MIPS, PowerPC)

Diagram inspired by Inferno: An Overview (PDF) 5 Current Project

Files Tetris Coffee Shell Clock Browser Window Manager Applications Window Manager

Dis VM

Libraries VDD System Calls Inferno Kernel Linux Interface Linux 3.17 on moto e4

Diagram inspired by Inferno: An Overview (PDF) 6 Hellaphone (video, source) •Ported Inferno to + Nook • Not really: emulated Inferno on them • “Dual booted” Inferno and Android •Added a lot of phone features: • Phone connectivity (with audio), • SMS, • Virtual keyboard, • Phone-friendly window manager…

7 Hellaphone

Shell Phone SMS

Window Manager Applications Hellaphone Window Manager Android Applications Java API Dis VM

Libraries VDD System Calls Libraries Dalvik (JVM) Inferno Kernel (emu/) Hardware Abstraction Layer Linux Interface Linux 2.x on Nexus S Bootloader Nexus S Hardware

Diagram inspired by Inferno: An Overview (PDF), Android Platform Architecture (Link) 8 9 ) (JVM) Link ( Android Runtime Runtime Android Java API Android Applications Android 4 HardwareAbstraction Layer Libraries

Hellaphone Android Platform Architecture ), PDF Bootloader ( Linux InterfaceLinux moto e4 Hardware e4 moto Linux 3.17 on on moto 3.17Linux SMS System System Calls Inferno: An Overview Phone Dis VM VDD Window Manager Window Inferno Kernel (emu/) Kernel Inferno Shell Window Manager Applications Window Libraries

Diagram inspired by Diagram inspired Current Project Current Done! •Except not really… • 1: Hellaphone may not boot on a modern hardware • 2: Modern phones require multitouch • Inferno has no multitouch interface • 3: Inferno-based ROM for a modern phone is nonexistent

10 Goal 1: Hellaphone 2017 •Want: Hellaphone features (phone support) + Linux 3 support •Hellaphone (2011) may boot without changes •Hellaphone may not boot • Before being modified a little • Before being modified a lot • Before merging with Inferno 2017 11 Goal 1: Hellaphone 2017 •Compile Hellaphone for moto e4 (instructions, readme) and see if it runs •If not, try adding small tweaks •If still doesn’t work, try booting Inferno (2017) on moto e4 and merge with Hellaphone

12 Goal 2: Touch Driver + API

•Currently: touch interpreted as clicks

from Hellaphone video (YouTube)

13 Goal 2: Touch Driver + API

•Want: Support multitouch beyond converting touch to mouse click •Focus: emu/port, emu/linux • We’re emulating Inferno on Linux •Interpret kernel touch events (drivers/input/touchscreen) •Both kernel  Dis and Dis  App

14 Goal 2: Touch Driver + API •Kernel  Dis: Add devtouch.c •Dis  App: Add devtouch.b,.m • In Limbo! •Add multitouch support to UI • System-wide multitouch gestures •Need to edit draw.*, emu

15 Existing Codebase •Hellaphone: phone-friendly UI • Good starting point for touch API testing •Linux kernel touchscreen codebase: 113,000+ lines • About 100-4000 lines for each touchscreen device :) •Inferno touch codebase: 0 lines • Tk UI + WM codebase: 3200 lines 16 Existing Codebase •Resources on Inferno to follow: pointer, cursor • Source files: devpointer.c, devpointer.b, devpointer.m (450 lines total) • Influences the Tk UI library, the draw module, the window manager, and the emu/linux/emu include file 17 Work: Hellaphone 2017 •Start from the 2011 Hellaphone repository •Results from booting Inferno on moto e4 (maybe nothing, maybe tweaks, maybe repository merge)

18 Work: Touch Driver + API

•Fresh Driver + Docs: • devtouch.c (300 lines) • devtouch.b (150 lines) • devtouch.m (20 lines) • man 3 devtouch, man 2 touch •Tweaks: • emu, to add devtouch • draw.*, to add touch ADT

19 Work: Touch Driver + API

•Major additions to existing code: • Tk UI library: tk.c,.b,.m, tkclient.b,.m (300 lines) • Window Manager: wm.b, wmclient.b,.m (100 lines) • Two-finger tap to open menu • Two-finger swipe down to close • Charon web browser: charon.b,.m • Implement “zooming” (30 lines) 20 Work: Touch Driver + API

•About 1000 lines total to add •Over around 20 files •0 lines of Assembly, so far •0 expected lines of Assembly to write

21 Documentation to Use •Codebase is not well-commented •Using source code as docs: • How pointer is used in Inferno • Touch follows similar pattern • Android: how touch is implemented • Good source of inspiration •Limbo PL documentation (link) •Other Inferno documentation (link) 22 Timeline

• Weeks 1-2: Boot Inferno on moto e4, additional time to do necessary changes • Week 3: Explore Android multitouch implementation, jumpstart on Limbo • Weeks 4-5: Implement devtouch and load devtouch onto Inferno and Dis • Weeks 6-7: Add multitouch API to Tk + draw • Week 8: Add gestures to WM + Charon

23 Obstacles… •Known: • Learning Limbo • Learning to write a decent driver • Booting Inferno on moto e4 • Potentially merging two branches •Good things to know: • No additional environment setup • Linux touchscreen interface is finite

24 Other Issues •No solid grasp of difficulty until driver coding begins •Tiny chance: Inferno just won’t load onto moto e4 • Fallback: Implement multitouch driver and API on NT (Windows) emulator • Use Windows touchscreen interface on the Surface

25 Awesome Outcomes •Touch API is universal across Inferno through Dis • Tweak emu/Nt/emu to include touch API => touch API for Inferno on Windows •Validate Hellaphone’s and Inferno’s portability across mobile phones 26 Looking Forward •Test portability of touch API on other platforms •Create additional gesture interpretations on WM and apps •Create moto e4 Purge ROM

27 The Purge ROM

Shell Phone SMS Window Manager Applications Window Manager Android Applications Java API Dis VM Android Runtime Libraries Libraries VDD System Calls (JVM) Inferno Kernel (emu/) Hardware Abstraction Layer Linux Interface Linux 3.17 on moto e4

Diagram inspired by Inferno: An Overview (PDF), Android Platform Architecture (Link) 28 The Purge ROM

Shell Phone SMS Purge: purging the Window Manager Applications bloat out from modern Window Manager Dis VM Purge: purging Java Libraries VDD System Calls and Android for a more Inferno Kernel (emu/) universal platform Linux Interface Linux 3.17 on moto e4 Purge: true to theme

Diagram inspired by Inferno: An Overview (PDF), Android Platform Architecture (Link) 29 purge touch-friendly Inferno on a 2017 phone

30