py: Add "io" module.

So far just includes "open" function, which should be supplied by a port.

TODO: Make the module #ifdef'ed.
diff --git a/py/builtin.h b/py/builtin.h
index 50269df..3120e5b 100644
--- a/py/builtin.h
+++ b/py/builtin.h
@@ -35,5 +35,6 @@
 
 extern const mp_obj_module_t mp_module_array;
 extern const mp_obj_module_t mp_module_collections;
+extern const mp_obj_module_t mp_module_io;
 extern const mp_obj_module_t mp_module_math;
 extern const mp_obj_module_t mp_module_micropython;
diff --git a/py/builtintables.c b/py/builtintables.c
index 2cb9240..03fb92e 100644
--- a/py/builtintables.c
+++ b/py/builtintables.c
@@ -121,6 +121,9 @@
     { MP_QSTR_micropython, (mp_obj_t)&mp_module_micropython },
 
     { MP_QSTR_array, (mp_obj_t)&mp_module_array },
+#if MICROPY_ENABLE_MOD_IO
+    { MP_QSTR_io, (mp_obj_t)&mp_module_io },
+#endif
     { MP_QSTR_collections, (mp_obj_t)&mp_module_collections },
 
 #if MICROPY_ENABLE_FLOAT
diff --git a/py/modio.c b/py/modio.c
new file mode 100644
index 0000000..ced3983
--- /dev/null
+++ b/py/modio.c
@@ -0,0 +1,30 @@
+#include "misc.h"
+#include "mpconfig.h"
+#include "qstr.h"
+#include "obj.h"
+#include "builtin.h"
+
+#if MICROPY_ENABLE_MOD_IO
+
+STATIC const mp_map_elem_t mp_module_io_globals_table[] = {
+    { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_io) },
+    // Note: mp_builtin_open_obj should be defined by port, it's not
+    // part of the core.
+    { MP_OBJ_NEW_QSTR(MP_QSTR_open), (mp_obj_t)&mp_builtin_open_obj },
+};
+
+STATIC const mp_map_t mp_module_io_globals = {
+    .all_keys_are_qstrs = 1,
+    .table_is_fixed_array = 1,
+    .used = sizeof(mp_module_io_globals_table) / sizeof(mp_map_elem_t),
+    .alloc = sizeof(mp_module_io_globals_table) / sizeof(mp_map_elem_t),
+    .table = (mp_map_elem_t*)mp_module_io_globals_table,
+};
+
+const mp_obj_module_t mp_module_io = {
+    .base = { &mp_type_module },
+    .name = MP_QSTR_io,
+    .globals = (mp_map_t*)&mp_module_io_globals,
+};
+
+#endif
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 09cc379..65577f0 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -105,6 +105,11 @@
 #define MICROPY_ENABLE_FLOAT (0)
 #endif
 
+// Whether to provide "io" module
+#ifndef MICROPY_ENABLE_MOD_IO
+#define MICROPY_ENABLE_MOD_IO (1)
+#endif
+
 // Whether to support slice object and correspondingly
 // slice subscript operators
 #ifndef MICROPY_ENABLE_SLICE
diff --git a/py/py.mk b/py/py.mk
index e2e83eb..0590292 100644
--- a/py/py.mk
+++ b/py/py.mk
@@ -78,6 +78,7 @@
 	builtintables.o \
 	modarray.o \
 	modcollections.o \
+	modio.o \
 	modmath.o \
 	modmicropython.o \
 	vm.o \
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index 368b0fc..06548d0 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -98,6 +98,7 @@
 Q(getattr)
 Q(hash)
 Q(id)
+Q(io)
 Q(int)
 Q(isinstance)
 Q(issubclass)
diff --git a/stm/file.c b/stm/file.c
index 40ac3ff..6a11623 100644
--- a/stm/file.c
+++ b/stm/file.c
@@ -92,3 +92,5 @@
     }
     return self;
 }
+
+MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_open_obj, pyb_io_open);
diff --git a/stm/mpconfigport.h b/stm/mpconfigport.h
index 3f48c43..4c8338b 100644
--- a/stm/mpconfigport.h
+++ b/stm/mpconfigport.h
@@ -18,6 +18,8 @@
 #define MICROPY_ENABLE_LFN          (0)
 #define MICROPY_LFN_CODE_PAGE       (1) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */
 
+extern const struct _mp_obj_fun_native_t mp_builtin_open_obj;
+
 // type definitions for the specific machine
 
 #define BYTES_PER_WORD (4)
diff --git a/unix-cpy/mpconfigport.h b/unix-cpy/mpconfigport.h
index 6351f0c..752df4f 100644
--- a/unix-cpy/mpconfigport.h
+++ b/unix-cpy/mpconfigport.h
@@ -3,6 +3,7 @@
 #define MICROPY_EMIT_CPYTHON        (1)
 #define MICROPY_ENABLE_LEXER_UNIX   (1)
 #define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_DOUBLE)
+#define MICROPY_ENABLE_MOD_IO       (0)
 
 // type definitions for the specific machine