]> Chaos Git - corbenik/corbenik.git/commitdiff
Just docs, basically.
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 31 May 2016 12:25:24 +0000 (08:25 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 31 May 2016 12:25:24 +0000 (08:25 -0400)
doc/bytecode.md [new file with mode: 0644]
doc/todo.md
source/patch/aadowngrade.c
source/patch/base.c
source/patch/prot.c

diff --git a/doc/bytecode.md b/doc/bytecode.md
new file mode 100644 (file)
index 0000000..6c9f6f3
--- /dev/null
@@ -0,0 +1,23 @@
+Bytecode format
+===================
+
+All instructions are dwords (four bytes) - this is for optimization reasons.
+
+Registers
+-------------------
+r1-r4 - General
+pc    - Current offset in bytecode
+mem   - Memory offset set.
+
+Instruction List
+-------------------
+1) call index
+2) add reg, reg
+3) sub reg, reg
+4) mul reg, reg
+5) div reg, reg
+6) mov reg/ref/imm, reg/ref/imm
+7) push reg
+8) pop <reg>
+9) .byte byte
+
index 2c13d3fb0fa79e32ff57482608cd55fd3468dcc8..2655d5bd53d401a97b69d84f2d009d1409817511 100644 (file)
@@ -1,32 +1,32 @@
 Next
 -------------
 
- * Make config file for corbenik plaintext. Nobody likes binary configs. They suck.
+ * Make config file for corbenik plaintext. Nobody likes binary configs. They suck. Massively. Especially when you fuck up a setting and need to change it on something that isn't a 3ds.
 
 Shortterm
 -------------
 
- * Implement some kind of curses-like backend and replace terrible printf rewind on top screen.
-   * Alternatively, implement a monochrome GUI.
-   * We also need UTF8 support. I want translation support.
-     * Dragging in freetype or a bitmap font tool.
-       * Ugh, VWF. Not like I haven't done it before...
-   * Kconfig?
+ * Implement some kind of GUI menu functionality.
+   * We also probably need UTF8 support. I want translations.
+     * Dragging in freetype or a bitmap font tool is likely needed.
+       * Also, VWF. Not like I haven't done it before...but ugh. It's still a pain.
+   * Kconfig-based menus?
+     * The logic can't be easily ported from linux, and would need to be reimplemented.
+
+ * Implement program loading as...something else. The current linker is broken. There's multiple ways to go about this:
+   * Figure out why it breaks. Fix it up. (Deemed impossible without static linking, which defeats the point.)
+   * Scripting language / VM maybe?
+     * Lua is the obvious choice, but there's a few negatives to this.
+     * It isn't terribly hard to write an assembler and bytecode VM. Maybe I'll do that.
+     * Has the advantages of code plus ARM9/ARM11 independence.
 
 Longterm
 -------------
+ * Optimize the buffer logic out of printf. Render directly to the FB and keep track of dirty areas instead.
  * Attempt to create a replacement handler for Service 0x3D, AKA OutputDebugString(void const, int) to log to a file on SD.
    * Might be a pipe dream. It still would be cool to capture debug logs from games.
      * Pretty sure this goes over JTAG on PARTNER units and anything else >/dev/null.
- * Config fragments for modules; and these need to be part of the modules, not corbenik's options menu.
-   * Oppa Kconfig style.
-     * Busybox may be helpful.
-       * Probably need to reimplement anyways due to lack of userland.
- * Implement program loading as...something else. The current linker is broken. There's multiple ways to go about this:
-   * Figure out why it breaks, and fix it up.
-   * Embed a function table in corbenik itself, and rip this table out and generate a header post-compile which can be used by modules.
- * Allow modules to be internal AND external, and to build either way. Think of the whole kmod-versus-builtin deal.
-   * All in all, this simplifies testing and allows multiple release types.
+ * Maybe replace svc 0xFF with something fancy.
  * Rewrite all hardcoded constants that are machine code as assembly.
-   * Read: all the patches
- * Change some stdlib functions to more closely imitate their real userland counterparts
+   * Read: all the patches.
+ * Change some stdlib functions to more closely imitate their userland counterparts
index 631682b263ba46cc0f94d6a51d52c5840ba5530e..23622fd8399c3ff207134b8237b8922fd6070e83 100644 (file)
@@ -2,6 +2,34 @@
 
 // Do you like examples?
 
+/* In bytecode assembly:
+
+  aadowngrade:
+    rel firm_mem
+    mov4 r1, pattern
+    mov4 r2, 6
+    call memfind
+    jmpz notfound
+
+  found:
+    add r1, 5
+    mov1 [r1], 0xE0
+    mov4 r1, 0
+    return
+
+  notfound:
+    mov4 r1, 1
+    return
+
+  pattern:
+    .byte 0x89
+    .byte 0x0A
+    .byte 0x81
+    .byte 0x42
+    .byte 0x02
+    .byte 0xD2
+ */
+
 PATCH(aadowngrade)
 {
        exefs_h* firm_p9_exefs = get_firm_proc9_exefs();
index 847740ab9164daac886dc889ef14007334028cf8..d5675b25cb6c4c3ad8285e7502d77939425ba3c9 100644 (file)
@@ -2,6 +2,19 @@
 
 // Do you like examples?
 
+/* Bytecode assembly:
+
+   example:
+     mov r1, 2
+     mov r2, string
+     call fprintf
+     mov r1, 0
+     return
+
+   string:
+     .str "Testing, testing, 1, 2, 3...\n"
+ */
+
 PATCH(example)
 {
     fprintf(stderr, "Testing, testing, 1, 2, 3, 4..\n");
index 869bb5e29e90f9f718c181a727fd8ec58f5a7f44..ef2ddc2a20603ee004e49a5fcf7270f45754a87c 100644 (file)
@@ -2,6 +2,42 @@
 
 // This patch applies the FIRM protection code needed for safe a9lh usage.
 
+/* Bytecode assembly:
+
+   firmprot:
+     rel firm_mem
+     mov r1, exe_str
+     mov r2, 4
+     call memfind
+     jmpz nostr
+
+     mov r3, r1
+     mov r1, 2
+     mov r2, str_atoff
+     call fprintf
+
+     
+
+   nostr:
+     mov r1, 2
+     mov r2, noexe_str_str
+     call fprintf
+     mov r1, 0
+     return
+
+   exe_str:
+     .str "exe:"
+   noexe_str_str:
+     .str "Couldn't find 'exe' string.\n"
+   str_atoff:
+     .str "Firmprot: 'exe:' string @ %x\n"
+   firmprot_code:
+     .byte 0x00
+     .byte 0x28
+     .byte 0x01
+     .byte 0xDA
+ */
+
 PATCH(firmprot)
 {
        exefs_h* firm_p9_exefs = get_firm_proc9_exefs();