├── .gitignore ├── .vscode ├── launch.json └── tasks.json ├── Makefile ├── README.md ├── doc ├── eclipse-debug-guide.md └── image │ ├── 01.PNG │ ├── 02-01.PNG │ ├── 02-02.PNG │ ├── 03.PNG │ ├── 04-01.PNG │ ├── 04-02.PNG │ ├── 04-03-01.PNG │ ├── 04-03.PNG │ ├── 04-04.PNG │ └── 05.PNG ├── kernel ├── Makefile ├── arch │ └── arm32 │ │ ├── Makefile │ │ ├── backtrace.c │ │ ├── backtrace.h │ │ ├── context_switch.S │ │ ├── entry.S │ │ ├── exception.c │ │ ├── include │ │ ├── arm32.h │ │ ├── asm │ │ │ ├── compiler.h │ │ │ └── unwind.h │ │ ├── asm_offset.h │ │ ├── barrier.h │ │ ├── div64.h │ │ ├── float.h │ │ ├── limits.h │ │ ├── mmu.h │ │ ├── smp.h │ │ ├── tlbflush.h │ │ └── types.h │ │ ├── irq.c │ │ ├── lib │ │ ├── Makefile │ │ ├── complaints.c │ │ ├── cpu │ │ │ ├── cache-v7.S │ │ │ ├── cache.c │ │ │ ├── cmd-cpuinfo.c │ │ │ └── cmd-mmuinfo.c │ │ ├── div64.S │ │ ├── lib1funcs.S │ │ ├── mmu.c │ │ ├── proc-arm920.S │ │ └── proc-v7.S │ │ ├── mach-realview │ │ ├── Makefile │ │ ├── Makefile.head │ │ ├── Makefile.mach │ │ ├── driver │ │ │ ├── ce-sp804.c │ │ │ ├── cs-sp804.c │ │ │ ├── fb-pl111.c │ │ │ ├── gpio-pl061.c │ │ │ ├── i2c-versatile.c │ │ │ ├── irq-gic.c │ │ │ ├── keyboard-pl050.c │ │ │ ├── mouse-pl050.c │ │ │ ├── rtc-ds1338.c │ │ │ ├── rtc-pl031.c │ │ │ ├── sdhci-pl180.c │ │ │ └── uart-pl011.c │ │ ├── dtree.S │ │ ├── head.S │ │ ├── include │ │ │ ├── configs.h │ │ │ ├── cpu.h │ │ │ ├── realview-gpio.h │ │ │ ├── realview-irq.h │ │ │ └── realview │ │ │ │ ├── reg-aaci.h │ │ │ │ ├── reg-eth.h │ │ │ │ ├── reg-mmc.h │ │ │ │ └── reg-sysctl.h │ │ ├── kernel.lds │ │ ├── realview-pb-a8.c │ │ └── realview-pb-a8.json │ │ ├── mach-x4418 │ │ ├── Makefile │ │ ├── Makefile.head │ │ ├── Makefile.mach │ │ ├── driver │ │ │ ├── battery-axp228.c │ │ │ ├── ce-samsung-timer.c │ │ │ ├── clk-s5p4418-pll.c │ │ │ ├── cs-samsung-timer.c │ │ │ ├── fb-s5p4418.c │ │ │ ├── gpio-s5p4418-alv.c │ │ │ ├── gpio-s5p4418.c │ │ │ ├── irq-pl192.c │ │ │ ├── irq-s5p4418-gpio.c │ │ │ ├── irq-s5p4418-gpioalv.c │ │ │ ├── pwm-samsung.c │ │ │ ├── regulator-axp228.c │ │ │ ├── samsung-timer.c │ │ │ ├── sdhci-xl00500.c │ │ │ ├── sdhci-xl00500.h │ │ │ ├── ts-gslx680.c │ │ │ └── uart-pl011.c │ │ ├── dtree.S │ │ ├── head.S │ │ ├── include │ │ │ ├── configs.h │ │ │ ├── cpu.h │ │ │ ├── s5p4418-gpio.h │ │ │ ├── s5p4418-irq.h │ │ │ ├── s5p4418-rstcon.h │ │ │ ├── s5p4418 │ │ │ │ ├── reg-clk.h │ │ │ │ ├── reg-dpa.h │ │ │ │ ├── reg-dpc.h │ │ │ │ ├── reg-i2c.h │ │ │ │ ├── reg-id.h │ │ │ │ ├── reg-mlc.h │ │ │ │ ├── reg-rstcon.h │ │ │ │ ├── reg-sys.h │ │ │ │ └── reg-wdg.h │ │ │ └── samsung-timer.h │ │ ├── kernel.lds │ │ ├── s5p4418-rstcon.c │ │ ├── tools │ │ │ ├── images │ │ │ │ ├── 2ndboot │ │ │ │ ├── nsih.txt │ │ │ │ └── nsih │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-2PCS-1GB.txt │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-2PCS-1GB.xls │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-2PCS-2GB.txt │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-2PCS-2GB.xls │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-4PCS-1GB.txt │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-4PCS-1GB.xls │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-4PCS-2GB.txt │ │ │ │ │ ├── NSIH-CPU-800MHZ-DDR3-4PCS-2GB.xls │ │ │ │ │ └── README.txt │ │ │ ├── linux │ │ │ │ ├── mk4418 │ │ │ │ └── s5p4418-sdmmc.sh │ │ │ └── windows │ │ │ │ └── mk4418.exe │ │ ├── x4418.c │ │ └── x4418.json │ │ └── syscalls.c ├── drivers │ ├── Makefile │ ├── battery │ │ ├── battery-sbs.c │ │ └── battery.c │ ├── block │ │ ├── Makefile │ │ ├── block.c │ │ ├── disk.c │ │ ├── partition │ │ │ ├── gpt.c │ │ │ ├── mbr.c │ │ │ └── partition.c │ │ └── romdisk │ │ │ └── romdisk.c │ ├── buzzer │ │ ├── buzzer-gpio.c │ │ ├── buzzer-pwm.c │ │ └── buzzer.c │ ├── clk │ │ ├── clk-divider.c │ │ ├── clk-fixed-factor.c │ │ ├── clk-fixed.c │ │ ├── clk-gate.c │ │ ├── clk-link.c │ │ ├── clk-mux.c │ │ ├── clk-ratio.c │ │ └── clk.c │ ├── clockevent │ │ └── clockevent.c │ ├── clocksource │ │ └── clocksource.c │ ├── console │ │ ├── console-uart.c │ │ └── console.c │ ├── dma │ │ └── dma.c │ ├── framebuffer │ │ └── framebuffer.c │ ├── gpio │ │ └── gpio.c │ ├── i2c │ │ ├── i2c-algo-bit.c │ │ ├── i2c-gpio.c │ │ └── i2c.c │ ├── input │ │ ├── Makefile │ │ ├── input.c │ │ ├── key-gpio-polled.c │ │ └── rc │ │ │ ├── rc-core.c │ │ │ ├── rc-decoder-nec.c │ │ │ └── rc-gpio.c │ ├── interrupt │ │ └── interrupt.c │ ├── led │ │ ├── led-gpio.c │ │ ├── led-pwm-bl.c │ │ ├── led.c │ │ ├── ledtrigger-general.c │ │ ├── ledtrigger-heartbeat.c │ │ └── ledtrigger.c │ ├── pwm │ │ ├── pwm-gpio.c │ │ └── pwm.c │ ├── regulator │ │ ├── regulator-gpio.c │ │ └── regulator.c │ ├── reset │ │ └── reset.c │ ├── rtc │ │ └── rtc.c │ ├── sd │ │ ├── sdcard.c │ │ └── sdhci.c │ ├── uart │ │ └── uart.c │ └── watchdog │ │ └── watchdog.c ├── fs │ ├── Makefile │ ├── dcache.c │ ├── fat32 │ │ ├── fat-node.c │ │ ├── fat32.c │ │ └── fat32.h │ ├── super.c │ ├── sys.c │ ├── sys.h │ ├── sys │ │ └── sys.c │ └── vfs.c ├── include │ ├── aes128.h │ ├── assert.h │ ├── atomic.h │ ├── battery │ │ └── battery.h │ ├── bcd.h │ ├── block.h │ ├── block │ │ ├── block.h │ │ ├── disk.h │ │ └── partition.h │ ├── bug.h │ ├── buzzer │ │ └── buzzer.h │ ├── calls.S │ ├── charset.h │ ├── class.h │ ├── clk │ │ └── clk.h │ ├── clockevent │ │ └── clockevent.h │ ├── clocksource │ │ └── clocksource.h │ ├── command │ │ └── command.h │ ├── common.h │ ├── compiler.h │ ├── console │ │ └── console.h │ ├── core │ │ ├── device.h │ │ ├── driver.h │ │ ├── dtree.h │ │ ├── event.h │ │ ├── initcall.h │ │ ├── kobj.h │ │ ├── ktime.h │ │ ├── machine.h │ │ ├── module.h │ │ ├── notifier.h │ │ └── seqlock.h │ ├── crc16.h │ ├── crc32.h │ ├── crc8.h │ ├── ctype.h │ ├── disk.h │ ├── dma │ │ └── dma.h │ ├── errno.h │ ├── fcntl.h │ ├── fifo.h │ ├── framebuffer │ │ └── framebuffer.h │ ├── gpio │ │ └── gpio.h │ ├── i2c │ │ ├── i2c-algo-bit.h │ │ └── i2c.h │ ├── input │ │ ├── input.h │ │ ├── keyboard.h │ │ └── rc │ │ │ ├── rc-core.h │ │ │ └── rc-decoder-nec.h │ ├── interrupt │ │ └── interrupt.h │ ├── io.h │ ├── irqflags.h │ ├── irqs.h │ ├── json.h │ ├── kconfigs.h │ ├── kernel.h │ ├── ldscript.h │ ├── led │ │ ├── led.h │ │ ├── ledstrip.h │ │ └── ledtrigger.h │ ├── lib.h │ ├── linkage.h │ ├── list.h │ ├── log2.h │ ├── malloc.h │ ├── math.h │ ├── memory.h │ ├── mm_types.h │ ├── pgtable-2level-types.h │ ├── pgtable.h │ ├── pgtable_2level.h │ ├── preempt.h │ ├── printk.h │ ├── ptrace.h │ ├── pwm │ │ └── pwm.h │ ├── queue.h │ ├── rbtree.h │ ├── rbtree_augmented.h │ ├── regulator │ │ └── regulator.h │ ├── reset │ │ └── reset.h │ ├── rtc │ │ └── rtc.h │ ├── sched.h │ ├── schedule.h │ ├── sd │ │ ├── sdcard.h │ │ ├── sdhci.h │ │ └── sdmmc.h │ ├── semaphore.h │ ├── sha1.h │ ├── sha256.h │ ├── shell │ │ ├── ctrlc.h │ │ ├── parser.h │ │ ├── readline.h │ │ └── shell.h │ ├── sizes.h │ ├── slist.h │ ├── softirq.h │ ├── spinlock.h │ ├── ssize.h │ ├── stddef.h │ ├── stdio.h │ ├── stdlib.h │ ├── string.h │ ├── sys │ │ ├── dirent.h │ │ ├── err.h │ │ ├── mm.h │ │ ├── param.h │ │ ├── signal.h │ │ ├── stat.h │ │ ├── syscall.h │ │ ├── time.h │ │ ├── times.h │ │ ├── unistd.h │ │ └── wait.h │ ├── syscall.h │ ├── syscalls.h │ ├── task.h │ ├── time │ │ ├── delay.h │ │ └── timer.h │ ├── typecheck.h │ ├── uart │ │ └── uart.h │ ├── unistd.h │ ├── usb │ │ ├── 2440usb.h │ │ └── ch9.h │ ├── version.h │ ├── vfs.h │ ├── waitqueue.h │ └── watchdog │ │ └── watchdog.h ├── init │ ├── Makefile │ ├── main.c │ └── version.c ├── kernel │ ├── Makefile │ ├── class │ │ └── class.c │ ├── command │ │ ├── cmd-cat.c │ │ ├── cmd-delay.c │ │ ├── cmd-exec.c │ │ ├── cmd-help.c │ │ ├── cmd-ls.c │ │ ├── cmd-mkdir.c │ │ ├── cmd-mv.c │ │ ├── cmd-ps.c │ │ ├── cmd-pwd.c │ │ ├── cmd-rmdir.c │ │ ├── cmd-touch.c │ │ ├── cmd-write.c │ │ └── command.c │ ├── core │ │ ├── device.c │ │ ├── driver.c │ │ ├── dtree.c │ │ ├── event.c │ │ ├── initcall.c │ │ ├── kobj.c │ │ ├── machine.c │ │ ├── notifier.c │ │ └── subsys.c │ ├── preempt.c │ ├── schedule.c │ ├── semaphore.c │ ├── shell │ │ └── readline.c │ ├── softirq.c │ ├── task.c │ ├── time │ │ ├── delay.c │ │ └── timer.c │ └── waitqueue.c ├── lib │ ├── Makefile │ ├── libc │ │ ├── Makefile │ │ ├── charset │ │ │ └── charset.c │ │ ├── crypto │ │ │ ├── aes128.c │ │ │ ├── crc16.c │ │ │ ├── crc32.c │ │ │ ├── crc8.c │ │ │ ├── sha1.c │ │ │ └── sha256.c │ │ ├── ctype │ │ │ └── ctype.c │ │ ├── errno │ │ │ ├── errno.c │ │ │ └── strerror.c │ │ ├── exit │ │ │ └── assert.c │ │ ├── malloc │ │ │ └── malloc.c │ │ ├── stdio │ │ │ ├── getchar.c │ │ │ ├── printf.c │ │ │ ├── putchar.c │ │ │ ├── scanf.c │ │ │ ├── snprintf.c │ │ │ ├── sprintf.c │ │ │ ├── sscanf.c │ │ │ ├── vasprintf.c │ │ │ ├── vsnprintf.c │ │ │ └── vsscanf.c │ │ ├── stdlib │ │ │ ├── abs.c │ │ │ ├── atof.c │ │ │ ├── atoi.c │ │ │ ├── atol.c │ │ │ ├── atoll.c │ │ │ ├── bsearch.c │ │ │ ├── div.c │ │ │ ├── labs.c │ │ │ ├── ldiv.c │ │ │ ├── llabs.c │ │ │ ├── lldiv.c │ │ │ ├── qsort.c │ │ │ ├── rand.c │ │ │ ├── strntoimax.c │ │ │ ├── strntoumax.c │ │ │ ├── strtod.c │ │ │ ├── strtoimax.c │ │ │ ├── strtol.c │ │ │ ├── strtoll.c │ │ │ ├── strtoul.c │ │ │ ├── strtoull.c │ │ │ └── strtoumax.c │ │ └── string │ │ │ ├── memchr.c │ │ │ ├── memcmp.c │ │ │ ├── memcpy.c │ │ │ ├── memmove.c │ │ │ ├── memscan.c │ │ │ ├── memset.c │ │ │ ├── strcasecmp.c │ │ │ ├── strcat.c │ │ │ ├── strchr.c │ │ │ ├── strcmp.c │ │ │ ├── strcoll.c │ │ │ ├── strcpy.c │ │ │ ├── strcspn.c │ │ │ ├── strdup.c │ │ │ ├── strlcat.c │ │ │ ├── strlcpy.c │ │ │ ├── strlen.c │ │ │ ├── strncasecmp.c │ │ │ ├── strncat.c │ │ │ ├── strnchr.c │ │ │ ├── strncmp.c │ │ │ ├── strncpy.c │ │ │ ├── strnicmp.c │ │ │ ├── strnlen.c │ │ │ ├── strnstr.c │ │ │ ├── strpbrk.c │ │ │ ├── strrchr.c │ │ │ ├── strsep.c │ │ │ ├── strspn.c │ │ │ └── strstr.c │ ├── libm │ │ ├── fabs.c │ │ ├── modf.c │ │ ├── pow.c │ │ ├── scalbn.c │ │ └── sqrt.c │ ├── libx │ │ ├── fifo.c │ │ ├── json.c │ │ ├── print_hex.c │ │ ├── queue.c │ │ ├── rbtree.c │ │ ├── slist.c │ │ └── ssize.c │ ├── lvgl │ │ ├── Makefile │ │ ├── lv_conf.h │ │ ├── lv_conf_checker.h │ │ ├── lv_conf_checker.py │ │ ├── lv_conf_templ.h │ │ ├── lv_core │ │ │ ├── lv_core.mk │ │ │ ├── lv_group.c │ │ │ ├── lv_group.h │ │ │ ├── lv_indev.c │ │ │ ├── lv_indev.h │ │ │ ├── lv_lang.c │ │ │ ├── lv_lang.h │ │ │ ├── lv_obj.c │ │ │ ├── lv_obj.h │ │ │ ├── lv_refr.c │ │ │ ├── lv_refr.h │ │ │ ├── lv_style.c │ │ │ ├── lv_style.h │ │ │ ├── lv_vdb.c │ │ │ └── lv_vdb.h │ │ ├── lv_draw │ │ │ ├── lv_draw.c │ │ │ ├── lv_draw.h │ │ │ ├── lv_draw.mk │ │ │ ├── lv_draw_arc.c │ │ │ ├── lv_draw_arc.h │ │ │ ├── lv_draw_img.c │ │ │ ├── lv_draw_img.h │ │ │ ├── lv_draw_label.c │ │ │ ├── lv_draw_label.h │ │ │ ├── lv_draw_line.c │ │ │ ├── lv_draw_line.h │ │ │ ├── lv_draw_rbasic.c │ │ │ ├── lv_draw_rbasic.h │ │ │ ├── lv_draw_rect.c │ │ │ ├── lv_draw_rect.h │ │ │ ├── lv_draw_triangle.c │ │ │ ├── lv_draw_triangle.h │ │ │ ├── lv_draw_vbasic.c │ │ │ └── lv_draw_vbasic.h │ │ ├── lv_fonts │ │ │ ├── lv_font_builtin.c │ │ │ ├── lv_font_builtin.h │ │ │ ├── lv_font_dejavu_10.c │ │ │ ├── lv_font_dejavu_10_cyrillic.c │ │ │ ├── lv_font_dejavu_10_latin_sup.c │ │ │ ├── lv_font_dejavu_20.c │ │ │ ├── lv_font_dejavu_20_cyrillic.c │ │ │ ├── lv_font_dejavu_20_latin_sup.c │ │ │ ├── lv_font_dejavu_30.c │ │ │ ├── lv_font_dejavu_30_cyrillic.c │ │ │ ├── lv_font_dejavu_30_latin_sup.c │ │ │ ├── lv_font_dejavu_40.c │ │ │ ├── lv_font_dejavu_40_cyrillic.c │ │ │ ├── lv_font_dejavu_40_latin_sup.c │ │ │ ├── lv_font_monospace_8.c │ │ │ ├── lv_font_symbol_10.c │ │ │ ├── lv_font_symbol_20.c │ │ │ ├── lv_font_symbol_30.c │ │ │ ├── lv_font_symbol_40.c │ │ │ └── lv_fonts.mk │ │ ├── lv_hal │ │ │ ├── lv_hal.h │ │ │ ├── lv_hal.mk │ │ │ ├── lv_hal_disp.c │ │ │ ├── lv_hal_disp.h │ │ │ ├── lv_hal_indev.c │ │ │ ├── lv_hal_indev.h │ │ │ ├── lv_hal_tick.c │ │ │ └── lv_hal_tick.h │ │ ├── lv_misc │ │ │ ├── lv_anim.c │ │ │ ├── lv_anim.h │ │ │ ├── lv_area.c │ │ │ ├── lv_area.h │ │ │ ├── lv_circ.c │ │ │ ├── lv_circ.h │ │ │ ├── lv_color.c │ │ │ ├── lv_color.h │ │ │ ├── lv_font.c │ │ │ ├── lv_font.h │ │ │ ├── lv_fs.c │ │ │ ├── lv_fs.h │ │ │ ├── lv_gc.c │ │ │ ├── lv_gc.h │ │ │ ├── lv_ll.c │ │ │ ├── lv_ll.h │ │ │ ├── lv_log.c │ │ │ ├── lv_log.h │ │ │ ├── lv_math.c │ │ │ ├── lv_math.h │ │ │ ├── lv_mem.c │ │ │ ├── lv_mem.h │ │ │ ├── lv_misc.mk │ │ │ ├── lv_symbol_def.h │ │ │ ├── lv_task.c │ │ │ ├── lv_task.h │ │ │ ├── lv_templ.c │ │ │ ├── lv_templ.h │ │ │ ├── lv_txt.c │ │ │ ├── lv_txt.h │ │ │ ├── lv_ufs.c │ │ │ └── lv_ufs.h │ │ ├── lv_objx │ │ │ ├── lv_arc.c │ │ │ ├── lv_arc.h │ │ │ ├── lv_bar.c │ │ │ ├── lv_bar.h │ │ │ ├── lv_btn.c │ │ │ ├── lv_btn.h │ │ │ ├── lv_btnm.c │ │ │ ├── lv_btnm.h │ │ │ ├── lv_calendar.c │ │ │ ├── lv_calendar.h │ │ │ ├── lv_canvas.c │ │ │ ├── lv_canvas.h │ │ │ ├── lv_cb.c │ │ │ ├── lv_cb.h │ │ │ ├── lv_chart.c │ │ │ ├── lv_chart.h │ │ │ ├── lv_cont.c │ │ │ ├── lv_cont.h │ │ │ ├── lv_ddlist.c │ │ │ ├── lv_ddlist.h │ │ │ ├── lv_gauge.c │ │ │ ├── lv_gauge.h │ │ │ ├── lv_img.c │ │ │ ├── lv_img.h │ │ │ ├── lv_imgbtn.c │ │ │ ├── lv_imgbtn.h │ │ │ ├── lv_kb.c │ │ │ ├── lv_kb.h │ │ │ ├── lv_label.c │ │ │ ├── lv_label.h │ │ │ ├── lv_led.c │ │ │ ├── lv_led.h │ │ │ ├── lv_line.c │ │ │ ├── lv_line.h │ │ │ ├── lv_list.c │ │ │ ├── lv_list.h │ │ │ ├── lv_lmeter.c │ │ │ ├── lv_lmeter.h │ │ │ ├── lv_mbox.c │ │ │ ├── lv_mbox.h │ │ │ ├── lv_objx.mk │ │ │ ├── lv_objx_templ.c │ │ │ ├── lv_objx_templ.h │ │ │ ├── lv_page.c │ │ │ ├── lv_page.h │ │ │ ├── lv_preload.c │ │ │ ├── lv_preload.h │ │ │ ├── lv_roller.c │ │ │ ├── lv_roller.h │ │ │ ├── lv_slider.c │ │ │ ├── lv_slider.h │ │ │ ├── lv_spinbox.c │ │ │ ├── lv_spinbox.h │ │ │ ├── lv_sw.c │ │ │ ├── lv_sw.h │ │ │ ├── lv_ta.c │ │ │ ├── lv_ta.h │ │ │ ├── lv_table.c │ │ │ ├── lv_table.h │ │ │ ├── lv_tabview.c │ │ │ ├── lv_tabview.h │ │ │ ├── lv_tileview.c │ │ │ ├── lv_tileview.h │ │ │ ├── lv_win.c │ │ │ └── lv_win.h │ │ ├── lv_porting │ │ │ ├── lv_port_disp_templ.c │ │ │ ├── lv_port_disp_templ.h │ │ │ ├── lv_port_fs_templ.c │ │ │ ├── lv_port_fs_templ.h │ │ │ ├── lv_port_indev_templ.c │ │ │ └── lv_port_indev_templ.h │ │ ├── lv_themes │ │ │ ├── lv_theme.c │ │ │ ├── lv_theme.h │ │ │ ├── lv_theme_alien.c │ │ │ ├── lv_theme_alien.h │ │ │ ├── lv_theme_default.c │ │ │ ├── lv_theme_default.h │ │ │ ├── lv_theme_material.c │ │ │ ├── lv_theme_material.h │ │ │ ├── lv_theme_mono.c │ │ │ ├── lv_theme_mono.h │ │ │ ├── lv_theme_nemo.c │ │ │ ├── lv_theme_nemo.h │ │ │ ├── lv_theme_night.c │ │ │ ├── lv_theme_night.h │ │ │ ├── lv_theme_templ.c │ │ │ ├── lv_theme_templ.h │ │ │ ├── lv_theme_zen.c │ │ │ ├── lv_theme_zen.h │ │ │ └── lv_themes.mk │ │ ├── lv_version.h │ │ ├── lvgl.h │ │ └── port │ │ │ ├── img_flower_icon.c │ │ │ ├── lv_test_stress.c │ │ │ ├── lv_test_theme_1.c │ │ │ ├── lv_test_theme_2.c │ │ │ ├── lv_tutorial_porting.c │ │ │ └── lv_tutorial_porting.h │ ├── microui │ │ ├── atlas.inl │ │ ├── main.c │ │ ├── microui.c │ │ ├── microui.h │ │ ├── renderer.c │ │ └── renderer.h │ └── vt100 │ │ ├── Makefile │ │ ├── console-virt.c │ │ ├── font5x8.h │ │ ├── test.c │ │ ├── vt100.c │ │ └── vt100.h ├── mm │ ├── Makefile │ └── memory.c └── scripts │ ├── Makefile.build │ ├── Makefile.conf │ ├── Makefile.include │ ├── fixdep.c │ └── kallsyms.c ├── tools └── qemu-system │ ├── linux │ ├── realview-dbg.sh │ └── realview-run.sh │ └── windows │ ├── realview-dbg.bat │ └── realview-run.bat └── user ├── Makefile ├── arch └── arm32 │ ├── Makefile │ ├── include │ ├── asm │ │ ├── compiler.h │ │ └── unwind.h │ ├── div64.h │ ├── limits.h │ ├── linkage.h │ └── types.h │ ├── lib │ └── div64.S │ └── mach-x4418 │ ├── Makefile │ ├── Makefile.mach │ ├── head.S │ ├── include │ └── configs.h │ └── user.lds ├── include ├── errno.h ├── kconfigs.h ├── stdio.h ├── stdlib.h └── syscall.h ├── lib ├── Makefile ├── printf.c ├── printf.h └── string.c ├── scripts ├── Makefile.build ├── Makefile.conf ├── Makefile.include └── fixdep.c └── src ├── Makefile ├── errno.c ├── lib.c ├── syscall.S └── test.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.[od] 2 | *.[oc]~ 3 | .*.cmd 4 | .cproject 5 | .project 6 | /.settings 7 | /tools/qemu-system/windows/* 8 | !/tools/qemu-system/windows/*.bat 9 | /tools/qemu-system/linux/* 10 | !/tools/qemu-system/linux/*.sh 11 | /.vscode/* 12 | !/.vscode/launch.json 13 | !/.vscode/tasks.json -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "(gdb) Launch", 9 | "type": "cppdbg", 10 | "request": "launch", 11 | "program": "${workspaceFolder}/kernel/system", 12 | "args": [], 13 | "stopAtEntry": false, 14 | "cwd": "${workspaceFolder}", 15 | "environment": [], 16 | "externalConsole": false, 17 | "MIMode": "gdb", 18 | "linux": { 19 | "MIMode": "gdb", 20 | "miDebuggerPath": "gdb-multiarch", 21 | "preLaunchTask": "debug-linux" 22 | }, 23 | "windows": { 24 | "MIMode": "gdb", 25 | "miDebuggerPath": "arm-linux-gnueabihf-gdb.exe", 26 | "preLaunchTask": "debug-windows" 27 | }, 28 | "miDebuggerServerAddress": "localhost:10001", 29 | "targetArchitecture": "ARM", 30 | "setupCommands": [ 31 | { 32 | "description": "Enable pretty-printing for gdb", 33 | "text": "-enable-pretty-printing", 34 | "ignoreFailures": true 35 | } 36 | ] 37 | } 38 | ] 39 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY : all kernel user dis clean 2 | 3 | all:kernel 4 | 5 | kernel: 6 | @$(MAKE) -s -C ./kernel all 7 | user: 8 | @$(MAKE) -s -C ./user all 9 | dis: 10 | @$(MAKE) -s -C ./kernel dis 11 | clean: 12 | @$(MAKE) -s -C ./kernel clean 13 | @$(MAKE) -s -C ./user clean 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MINE操作系统内核 2 | ## 简介 3 | 本项目将《一个64位操作系统的设计与实现》(田宇)一书中的MINE操作系统内核移植到ARM处理器上。 4 | ## 使用指南 5 | ### 准备 6 | 一台PC 7 | ### 运行环境搭建 8 | #### windows 9 | - [安装git shell](https://gitforwindows.org/) 10 | - [安装MinGW](http://www.mingw.org/) 11 | 由于编译MINE需要实现编译一些本地应用,所以这是必须的,最后将bin目录添加入环境变量 12 | - [安装工具链](https://pan.baidu.com/s/18nwU9GWxeKk57CfIWhW0ng ) 13 | 提取码:3zas 14 | 解压,并将bin,arm-linux-gnieabihf/bin目录添加入环境变量。 15 | bin目录包含常用的Linux基础命令,**必须放在第一个**,否则编译会失败。 16 | 原因如下:编译需要find命令,但Linux和Windows的find命令用法不同,当然git shell内置了find,或许不会出现这种问题。 17 | 另外这种方式可能会导致一些应用不能正常工作,可以通过恢复环境变量修复。 18 | - [安装qemu](https://pan.baidu.com/s/17vjjLS7i70nGXm_ZLGWv5A) 19 | 提取码:h5kg 20 | 解压到项目根目录下的tools文件夹,没有请自己创建 21 | #### WSL & Linux 22 | ```sh 23 | sudo apt-get install git 24 | sudo apt-get install build-essential 25 | sudo apt-get install gcc-arm-linux-gnueabihf 26 | sudo apt-get install gdb-multiarch 27 | sudo apt-get install qemu-system-arm 28 | ``` 29 | WSL默认没有安装图形界面,需要你手动安装。这里自行百度。 30 | ### 编译 31 | Windows右击打开git bash运行以下命令 32 | ```sh 33 | make -j4 CROSS_COMPILE=arm-linux-gnueabihf- PLATFORM=arm32-realview 34 | ``` 35 | ### 运行 36 | - 以Windows为例,运行tools/qemu-system/windows/realview-run.bat 37 | ### 调试环境搭建 38 | #### eclipse 39 | * [安装eclipse CDT](https://pan.baidu.com/s/1jM5nixlzl3XwzxNH0sI1sQ) 40 | 提取码:yrw7 41 | eclipse官网下载亦可 42 | * [eclipse调试环境搭建指南](/doc/eclipse-debug-guide.md) 43 | #### vscode 44 | * 项目已包含配置文件,F5直接运行 45 | ## TODO 46 | - [x] 完善vfs,支持多文件系统 47 | - [ ] 开发devfs,抽象设备文件 48 | - [ ] 移植C库 49 | - [ ] 移植基础命令 50 | - [ ] 支持RISC-V 51 | - [x] 支持armv7 52 | - [ ] 移植字体引擎 53 | - [ ] 移植GUI 54 | 55 | ## 联系 56 | - MINE官方QQ群:144571173 57 | - 个人QQ:891085309 58 | -------------------------------------------------------------------------------- /doc/eclipse-debug-guide.md: -------------------------------------------------------------------------------- 1 | # eclipse调试环境搭建指南 2 | ## 准备 3 | 使项目根目录如图所示。 4 | ![](/doc/image/01.PNG) 5 | ## 创建项目 6 | 选择`File` `Project` ,选择如图所示,点击`next`。 7 | ![](/doc/image/02-01.PNG) 8 | 输入`Project Name`,选择项目路径,选择`none`,点击`Finish`。 9 | ![](/doc/image/02-02.PNG) 10 | ## 安装调试工具 11 | 点击菜单栏`Help`,`Install New software`,进入如下界面,完成图示操作。 12 | ![](/doc/image/03.PNG) 13 | ## 创建Debug配置 14 | 点击`New Launch Configuration`创建新配置。 15 | ![](/doc/image/04-01.PNG) 16 | 按图所示选择相应项目,点击`Next`。 17 | ![](/doc/image/04-02.PNG) 18 | 选择项目,设置最终执行文件路径,点击`Build Configuartion`。**注意:如果提示缺少相应文件,无法完成操作,可以创建一个临时的假文件** 19 | ![](/doc/image/04-03.PNG) 20 | 输入以下内容,点击`Apply and Close`。 21 | ``` 22 | all -j16 CROSS_COMPILE=arm-linux-gnueabihf- PLATFORM=arm32-realview G=on 23 | ``` 24 | ![](/doc/image/04-03-01.PNG) 25 | 点击设置`Browse`,选择之前的工具链目录下的compiler\arm-linux-gnueabihf\bin\arm-linux-gnueabihf-gdb.exe,设置Port为10001,默认值经常会被占用。 26 | ![](/doc/image/04-04.PNG) 27 | ## 调试 28 | 点击Debug按钮,等待操作完成。如果没有启动QEMU,可以在tools目录下手动运行 29 | realview-dbg.bat。 30 | ![](/doc/image/05.PNG) -------------------------------------------------------------------------------- /doc/image/01.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/01.PNG -------------------------------------------------------------------------------- /doc/image/02-01.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/02-01.PNG -------------------------------------------------------------------------------- /doc/image/02-02.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/02-02.PNG -------------------------------------------------------------------------------- /doc/image/03.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/03.PNG -------------------------------------------------------------------------------- /doc/image/04-01.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/04-01.PNG -------------------------------------------------------------------------------- /doc/image/04-02.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/04-02.PNG -------------------------------------------------------------------------------- /doc/image/04-03-01.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/04-03-01.PNG -------------------------------------------------------------------------------- /doc/image/04-03.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/04-03.PNG -------------------------------------------------------------------------------- /doc/image/04-04.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/04-04.PNG -------------------------------------------------------------------------------- /doc/image/05.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/doc/image/05.PNG -------------------------------------------------------------------------------- /kernel/arch/arm32/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += $(MACH)/ 2 | obj-y += lib/ 3 | obj-y += $(patsubst $(srctree)/$(src)/%.c, %.o, $(wildcard $(srctree)/$(src)/*.c)) \ 4 | $(patsubst $(srctree)/$(src)/%.S, %.o, $(wildcard $(srctree)/$(src)/*.S)) -------------------------------------------------------------------------------- /kernel/arch/arm32/backtrace.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __BACKTRACE_H__ 17 | 18 | #define __BACKTRACE_H__ 19 | 20 | void backtrace(unsigned long regs); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /kernel/arch/arm32/context_switch.S: -------------------------------------------------------------------------------- 1 | #include 2 | ENTRY(__switch_to) 3 | mov ip, r0 4 | stmia ip!, {r4 - sl, fp, sp, lr} 5 | vstmia ip!, {d8 - d15} 6 | mov r4, r1 7 | vldmdb r4!, {d8 - d15} 8 | ldmdb r4, {r4 - sl, fp, sp, pc} 9 | -------------------------------------------------------------------------------- /kernel/arch/arm32/include/asm/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_ARM_COMPILER_H 2 | #define __ASM_ARM_COMPILER_H 3 | 4 | /* 5 | * This is used to ensure the compiler did actually allocate the register we 6 | * asked it for some inline assembly sequences. Apparently we can't trust 7 | * the compiler from one version to another so a bit of paranoia won't hurt. 8 | * This string is meant to be concatenated with the inline asm string and 9 | * will cause compilation to stop on mismatch. 10 | * (for details, see gcc PR 15089) 11 | */ 12 | #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t" 13 | 14 | 15 | #endif /* __ASM_ARM_COMPILER_H */ 16 | -------------------------------------------------------------------------------- /kernel/arch/arm32/include/asm/unwind.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_UNWIND_H 2 | #define __ASM_UNWIND_H 3 | 4 | #ifdef CONFIG_ARM_UNWIND 5 | #define UNWIND(code...) code 6 | #else 7 | #define UNWIND(code...) 8 | #endif 9 | 10 | #endif /* __ASM_UNWIND_H */ 11 | -------------------------------------------------------------------------------- /kernel/arch/arm32/include/asm_offset.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_OFFSETS_H__ 2 | #define __ASM_OFFSETS_H__ 3 | 4 | #define S_R0 0 /* offsetof(struct pt_regs, ARM_r0) @ */ 5 | #define S_R1 4 /* offsetof(struct pt_regs, ARM_r1) @ */ 6 | #define S_R2 8 /* offsetof(struct pt_regs, ARM_r2) @ */ 7 | #define S_R3 12 /* offsetof(struct pt_regs, ARM_r3) @ */ 8 | #define S_R4 16 /* offsetof(struct pt_regs, ARM_r4) @ */ 9 | #define S_R5 20 /* offsetof(struct pt_regs, ARM_r5) @ */ 10 | #define S_R6 24 /* offsetof(struct pt_regs, ARM_r6) @ */ 11 | #define S_R7 28 /* offsetof(struct pt_regs, ARM_r7) @ */ 12 | #define S_R8 32 /* offsetof(struct pt_regs, ARM_r8) @ */ 13 | #define S_R9 36 /* offsetof(struct pt_regs, ARM_r9) @ */ 14 | #define S_R10 40 /* offsetof(struct pt_regs, ARM_r10) @ */ 15 | #define S_FP 44 /* offsetof(struct pt_regs, ARM_fp) @ */ 16 | #define S_IP 48 /* offsetof(struct pt_regs, ARM_ip) @ */ 17 | #define S_SP 52 /* offsetof(struct pt_regs, ARM_sp) @ */ 18 | #define S_LR 56 /* offsetof(struct pt_regs, ARM_lr) @ */ 19 | #define S_PC 60 /* offsetof(struct pt_regs, ARM_pc) @ */ 20 | #define S_PSR 64 /* offsetof(struct pt_regs, ARM_cpsr) @ */ 21 | #define S_OLD_R0 68 /* offsetof(struct pt_regs, ARM_ORIG_r0) @ */ 22 | #define S_FRAME_SIZE 72 /* sizeof(struct pt_regs) @ */ 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /kernel/arch/arm32/include/barrier.h: -------------------------------------------------------------------------------- 1 | #ifndef __ARM32_BARRIER_H__ 2 | #define __ARM32_BARRIER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t"); 9 | 10 | #if __ARM32_ARCH__ == 5 11 | #define isb() __asm__ __volatile__ ("" : : : "memory") 12 | #define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory") 13 | #define dmb() __asm__ __volatile__ ("" : : : "memory") 14 | #elif __ARM32_ARCH__ == 6 15 | #define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" : : "r" (0) : "memory") 16 | #define dsb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0) : "memory") 17 | #define dmb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory") 18 | #else 19 | #define isb() __asm__ __volatile__ ("isb" : : : "memory") 20 | #define dsb() __asm__ __volatile__ ("dsb" : : : "memory") 21 | #define dmb() __asm__ __volatile__ ("dmb" : : : "memory") 22 | #endif 23 | 24 | /* Read and write memory barrier */ 25 | #define mb() dsb() 26 | /* Read memory barrier */ 27 | #define rmb() dsb() 28 | /* Write memory barrier */ 29 | #define wmb() dsb() 30 | 31 | /* SMP read and write memory barrier */ 32 | #define smp_mb() dmb() 33 | /* SMP read memory barrier */ 34 | #define smp_rmb() dmb() 35 | /* SMP write memory barrier */ 36 | #define smp_wmb() dmb() 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __ARM32_BARRIER_H__ */ 43 | -------------------------------------------------------------------------------- /kernel/arch/arm32/include/smp.h: -------------------------------------------------------------------------------- 1 | #ifndef __SMP_H__ 2 | #define __SMP_H__ 3 | 4 | #include 5 | 6 | 7 | #define smp_processor_id() (current->cpu_id) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /kernel/arch/arm32/irq.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void arch_irq_handler_default(struct pt_regs *regs) { 8 | arm32_do_irq(); 9 | do_softirq(); 10 | assert(preempt_count()>=0); 11 | if(!preempt_count()) 12 | schedule(); 13 | } 14 | -------------------------------------------------------------------------------- /kernel/arch/arm32/lib/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += div64.o 2 | obj-y += complaints.o 3 | obj-y += mmu.o 4 | obj-y += proc-v7.o 5 | obj-y += cpu/ -------------------------------------------------------------------------------- /kernel/arch/arm32/lib/complaints.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int raise(int signum) { 5 | LOG("raise"); 6 | assert(0); 7 | return 0; 8 | } 9 | void __aeabi_unwind_cpp_pr0(void) { 10 | LOG("__aeabi_unwind_cpp_pr0"); 11 | }; 12 | void __aeabi_unwind_cpp_pr1(void) { 13 | LOG("__aeabi_unwind_cpp_pr1"); 14 | }; 15 | 16 | void __div0(void) 17 | { 18 | LOG("Attempting division by 0!"); 19 | } 20 | -------------------------------------------------------------------------------- /kernel/arch/arm32/lib/cpu/cache-v7.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if __ARM32_ARCH__ == 7 4 | 5 | .macro dcache_line_size, reg, tmp 6 | mrc p15, 1, \tmp, c0, c0, 0 @ read CSIDR 7 | and \tmp, \tmp, #7 @ cache line size encoding 8 | mov \reg, #16 @ size offset 9 | mov \reg, \reg, lsl \tmp @ actual cache line size 10 | .endm 11 | 12 | ENTRY(v7_cache_inv_range) 13 | dcache_line_size r2, r3 14 | sub r3, r2, #1 15 | tst r0, r3 16 | bic r0, r0, r3 17 | mcrne p15, 0, r0, c7, c14, 1 @ clean & invalidate D / U line 18 | 19 | tst r1, r3 20 | bic r1, r1, r3 21 | mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D / U line 22 | 1: 23 | mcr p15, 0, r0, c7, c6, 1 @ invalidate D / U line 24 | add r0, r0, r2 25 | cmp r0, r1 26 | blo 1b 27 | dsb 28 | mov pc, lr 29 | ENDPROC(v7_cache_inv_range) 30 | 31 | ENTRY(v7_cache_clean_range) 32 | dcache_line_size r2, r3 33 | sub r3, r2, #1 34 | bic r0, r0, r3 35 | 1: 36 | mcr p15, 0, r0, c7, c10, 1 @ clean D / U line 37 | add r0, r0, r2 38 | cmp r0, r1 39 | blo 1b 40 | dsb 41 | mov pc, lr 42 | ENDPROC(v7_cache_clean_range) 43 | 44 | ENTRY(v7_cache_flush_range) 45 | dcache_line_size r2, r3 46 | sub r3, r2, #1 47 | bic r0, r0, r3 48 | 1: 49 | mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D / U line 50 | add r0, r0, r2 51 | cmp r0, r1 52 | blo 1b 53 | dsb 54 | mov pc, lr 55 | ENDPROC(v7_cache_flush_range) 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /kernel/arch/arm32/lib/proc-arm920.S: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | * The size of one data cache line. 5 | */ 6 | #define CACHE_DLINESIZE 32 7 | 8 | /* 9 | * The number of data cache segments. 10 | */ 11 | #define CACHE_DSEGMENTS 8 12 | 13 | /* 14 | * The number of lines in a cache segment. 15 | */ 16 | #define CACHE_DENTRIES 64 17 | 18 | ENTRY(cpu_arm920_switch_mm) 19 | mov ip, #0 20 | @ && 'Clean & Invalidate whole DCache' 21 | @ && Re-written to use Index Ops. 22 | @ && Uses registers r1, r3 and ip 23 | 24 | mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments 25 | 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries 26 | 2: mcr p15, 0, r3, c7, c14, 2 @ clean & invalidate D index 27 | subs r3, r3, #1 << 26 28 | bcs 2b @ entries 63 to 0 29 | subs r1, r1, #1 << 5 30 | bcs 1b @ segments 7 to 0 31 | 32 | mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache 33 | mcr p15, 0, ip, c7, c10, 4 @ drain WB 34 | mcr p15, 0, r0, c2, c0, 0 @ load page table pointer 35 | mcr p15, 0, ip, c8, c7, 0 @ invalidate I & D TLBs 36 | 37 | mov pc, lr 38 | 39 | /* 40 | * flush_kern_cache_all() 41 | * 42 | * Clean and invalidate the entire cache. 43 | */ 44 | ENTRY(arm920_flush_kern_cache_all) 45 | mov ip, #0 46 | __flush_whole_cache: 47 | mov r1, #(CACHE_DSEGMENTS - 1) << 5 @ 8 segments 48 | 1: orr r3, r1, #(CACHE_DENTRIES - 1) << 26 @ 64 entries 49 | 2: mcr p15, 0, r3, c7, c14, 2 @ clean+invalidate D index 50 | subs r3, r3, #1 << 26 51 | bcs 2b @ entries 63 to 0 52 | subs r1, r1, #1 << 5 53 | bcs 1b @ segments 7 to 0 54 | mcr p15, 0, ip, c7, c5, 0 @ invalidate I cache 55 | mcr p15, 0, ip, c7, c10, 4 @ drain WB 56 | mov pc, lr 57 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/Makefile: -------------------------------------------------------------------------------- 1 | extra-y += head.o 2 | 3 | obj-y += driver/ 4 | obj-y += $(filter-out $(extra-y), \ 5 | $(patsubst $(srctree)/$(src)/%.c, %.o, $(wildcard $(srctree)/$(src)/*.c)) \ 6 | $(patsubst $(srctree)/$(src)/%.S, %.o, $(wildcard $(srctree)/$(src)/*.S))) 7 | 8 | $(obj)/dtree.o : $(src)/realview-pb-a8.json 9 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/Makefile.head: -------------------------------------------------------------------------------- 1 | HEAD_FILES += 2 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/dtree.S: -------------------------------------------------------------------------------- 1 | .section .dtree, "a" 2 | .incbin "arch/arm32/mach-realview/realview-pb-a8.json" 3 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/include/configs.h: -------------------------------------------------------------------------------- 1 | #ifndef __OVERRIDE_CONFIGS_H__ 2 | #define __OVERRIDE_CONFIGS_H__ 3 | 4 | #define CONFIG_CPU_TLB_V7 5 | 6 | #define CONFIG_PAGE_OFFSET (0) 7 | #define CONFIG_TASK_SIZE (0x70000000) 8 | #define CONFIG_CODE_START_ADDR (0x800000) 9 | #define CONFIG_STACK_START_ADDR (0xa00000) 10 | #define CONFIG_BRK_START_ADDR (0xc00000) 11 | #define CONFIG_BLOCK_DEV "card.sdhci-pl180.0.p0" 12 | #define CONFIG_FB_DEV "fb-pl111.0" 13 | #endif /* __OVERRIDE_CONFIGS_H__ */ 14 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/include/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef __CPU_H__ 2 | #define __CPU_H__ 3 | 4 | #define NR_CPUS 1 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/include/realview-gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef __REALVIEW_GPIO_H__ 2 | #define __REALVIEW_GPIO_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define REALVIEW_GPIO0(x) (x) 9 | #define REALVIEW_GPIO1(x) (x + 8) 10 | #define REALVIEW_GPIO2(x) (x + 16) 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif /* __REALVIEW_GPIO_H__ */ 17 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/include/realview-irq.h: -------------------------------------------------------------------------------- 1 | #ifndef __REALVIEW_IRQ_H__ 2 | #define __REALVIEW_IRQ_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define REALVIEW_IRQ_WDOG (32 + 0) 9 | #define REALVIEW_IRQ_SOFT (32 + 1) 10 | #define REALVIEW_IRQ_DBGURX (32 + 2) 11 | #define REALVIEW_IRQ_DBGUTX (32 + 3) 12 | #define REALVIEW_IRQ_TMIER0_1 (32 + 4) 13 | #define REALVIEW_IRQ_TMIER2_3 (32 + 5) 14 | #define REALVIEW_IRQ_GPIO0 (32 + 6) 15 | #define REALVIEW_IRQ_GPIO1 (32 + 7) 16 | #define REALVIEW_IRQ_GPIO2 (32 + 8) 17 | #define REALVIEW_IRQ_RTC (32 + 10) 18 | #define REALVIEW_IRQ_SSP (32 + 11) 19 | #define REALVIEW_IRQ_UART0 (32 + 12) 20 | #define REALVIEW_IRQ_UART1 (32 + 13) 21 | #define REALVIEW_IRQ_UART2 (32 + 14) 22 | #define REALVIEW_IRQ_UART3 (32 + 15) 23 | #define REALVIEW_IRQ_SCI (32 + 16) 24 | #define REALVIEW_IRQ_MMCI0A (32 + 17) 25 | #define REALVIEW_IRQ_MMCI0B (32 + 18) 26 | #define REALVIEW_IRQ_AACI (32 + 19) 27 | #define REALVIEW_IRQ_KMI0 (32 + 20) 28 | #define REALVIEW_IRQ_KMI1 (32 + 21) 29 | #define REALVIEW_IRQ_CHARLCD (32 + 22) 30 | #define REALVIEW_IRQ_LCD (32 + 23) 31 | #define REALVIEW_IRQ_DMA (32 + 24) 32 | #define REALVIEW_IRQ_PWRFAIL (32 + 25) 33 | #define REALVIEW_IRQ_PISMO (32 + 26) 34 | #define REALVIEW_IRQ_DOC (32 + 27) 35 | #define REALVIEW_IRQ_ETH (32 + 28) 36 | #define REALVIEW_IRQ_USB (32 + 29) 37 | #define REALVIEW_IRQ_TSPEN (32 + 30) 38 | #define REALVIEW_IRQ_TSKPAD (32 + 31) 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* __REALVIEW_IRQ_H__ */ 45 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/include/realview/reg-eth.h: -------------------------------------------------------------------------------- 1 | #ifndef __REALVIEW_REG_ETH_H__ 2 | #define __REALVIEW_REG_ETH_H__ 3 | 4 | #define REALVIEW_ETH_RX_DATA_FIFO (0x4e000000 + 0x00) 5 | #define REALVIEW_ETH_TX_DATA_FIFO (0x4e000000 + 0x20) 6 | #define REALVIEW_ETH_RX_STATUS_FIFO (0x4e000000 + 0x40) 7 | #define REALVIEW_ETH_TX_STATUS_FIFO (0x4e000000 + 0x48) 8 | 9 | #define REALVIEW_ETH_ID_REV (0x4e000000 + 0x50) 10 | #define REALVIEW_ETH_BYTE_TEST (0x4e000000 + 0x64) 11 | #define REALVIEW_ETH_FIFO_INT (0x4e000000 + 0x68) 12 | #define REALVIEW_ETH_RX_CFG (0x4e000000 + 0x6c) 13 | #define REALVIEW_ETH_TX_CFG (0x4e000000 + 0x70) 14 | 15 | #define REALVIEW_ETH_HW_CFG (0x4e000000 + 0x74) 16 | 17 | #define REALVIEW_ETH_RX_DP_CTRL (0x4e000000 + 0x78) 18 | 19 | #define REALVIEW_ETH_RX_FIFO_INF (0x4e000000 + 0x7c) 20 | #define REALVIEW_ETH_TX_FIFO_INF (0x4e000000 + 0x80) 21 | #define REALVIEW_ETH_PMT_CTRL (0x4e000000 + 0x84) 22 | 23 | #define REALVIEW_ETH_MAC_CSR_CMD (0x4e000000 + 0xa4) 24 | #define REALVIEW_ETH_MAC_CSR_DATA (0x4e000000 + 0xa8) 25 | 26 | #define REALVIEW_ETH_AFC_CFG (0x4e000000 + 0xac) 27 | 28 | #endif /* __REALVIEW_REG_ETH_H__ */ 29 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-realview/include/realview/reg-sysctl.h: -------------------------------------------------------------------------------- 1 | #ifndef __REALVIEW_REG_SYSCTL_H__ 2 | #define __REALVIEW_REG_SYSCTL_H__ 3 | 4 | #define REALVIEW_SYSCTL_BASE (0x10000000) 5 | 6 | #define SYSCTL_ID (0x00) 7 | #define SYSCTL_SW (0x04) 8 | #define SYSCTL_LED (0x08) 9 | #define SYSCTL_OSC0 (0x0c) 10 | #define SYSCTL_OSC1 (0x10) 11 | #define SYSCTL_OSC2 (0x14) 12 | #define SYSCTL_OSC3 (0x18) 13 | #define SYSCTL_OSC4 (0x1c) 14 | #define SYSCTL_LOCK (0x20) 15 | #define SYSCTL_100HZ (0x24) 16 | #define SYSCTL_RESET (0x40) 17 | 18 | #endif /* __REALVIEW_REG_SYSCTL_H__ */ 19 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/Makefile: -------------------------------------------------------------------------------- 1 | extra-y += head.o 2 | 3 | obj-y += driver/ 4 | obj-y += $(filter-out $(extra-y), \ 5 | $(patsubst $(srctree)/$(src)/%.c, %.o, $(wildcard $(srctree)/$(src)/*.c)) \ 6 | $(patsubst $(srctree)/$(src)/%.S, %.o, $(wildcard $(srctree)/$(src)/*.S))) 7 | 8 | $(obj)/dtree.o : $(src)/x4418.json 9 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/Makefile.head: -------------------------------------------------------------------------------- 1 | HEAD_FILES += 2 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/Makefile.mach: -------------------------------------------------------------------------------- 1 | DEFINES += -D__ARM32_ARCH__=7 -D__CORTEX_A9__ -D__ARM32_NEON__ 2 | 3 | WFLAGS := -w 4 | OPTFLAGS := -O3 5 | 6 | ifeq ("$(origin G)", "command line") 7 | ifeq ($(G),on) 8 | OPTFLAGS := -O0 -g -ggdb 9 | endif 10 | endif 11 | 12 | ASFLAGS := -ffunction-sections -fdata-sections -fno-PIE $(WFLAGS) $(OPTFLAGS) 13 | CFLAGS := -ffunction-sections -fdata-sections -fno-PIE $(WFLAGS) $(OPTFLAGS) 14 | LDFLAGS := -T $(srctree)/arch/$(ARCH)/$(MACH)/kernel.lds -nostdlib --build-id=none -gc-sections 15 | 16 | MCFLAGS := -std=gnu99 \ 17 | -march=armv7-a -mtune=cortex-a9 -mfpu=neon-fp16 \ 18 | -ffreestanding -mfloat-abi=hard -fsigned-char \ 19 | -fno-omit-frame-pointer \ 20 | -marm -mno-thumb-interwork -mno-unaligned-access 21 | 22 | MASFLAGS := -D__ASSEMBLY__ 23 | MLDFLAGS := 24 | 25 | LIBDIRS := -L $(dir $(shell $(CC) -march=armv7-a -mtune=cortex-a9 -mfpu=neon-fp16 -ffreestanding -mfloat-abi=hard -print-libgcc-file-name)) 26 | LIBS := -lgcc 27 | 28 | NSIH := $(srctree)/arch/$(ARCH)/$(MACH)/tools/images/nsih.txt 29 | 30 | xend: 31 | @echo [USB DOWNLOAD] 32 | @udown $(NSIH) $(X_NAME).bin 33 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/dtree.S: -------------------------------------------------------------------------------- 1 | .section .dtree, "a" 2 | .incbin "arch/arm32/mach-x4418/x4418.json" 3 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/configs.h: -------------------------------------------------------------------------------- 1 | #ifndef __OVERRIDE_CONFIGS_H__ 2 | #define __OVERRIDE_CONFIGS_H__ 3 | 4 | #define CONFIG_CPU_TLB_V7 5 | 6 | #define CONFIG_PAGE_OFFSET (0) 7 | #define CONFIG_TASK_SIZE (0x40100000) 8 | #define CONFIG_CODE_START_ADDR (0x800000) 9 | #define CONFIG_STACK_START_ADDR (0xa00000) 10 | #define CONFIG_BRK_START_ADDR (0xc00000) 11 | #define CONFIG_BLOCK_DEV "card.sdhci-xl00500.1.p0" 12 | #define CONFIG_FB_DEV "fb-s5p4418.0" 13 | 14 | #endif /* __OVERRIDE_CONFIGS_H__ */ 15 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef __CPU_H__ 2 | #define __CPU_H__ 3 | 4 | #define NR_CPUS 1 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/s5p4418/reg-dpa.h: -------------------------------------------------------------------------------- 1 | #ifndef __S5P4418_REG_DPA_H__ 2 | #define __S5P4418_REG_DPA_H__ 3 | 4 | #define S5P4418_DPA_BASE (0x00000000) 5 | 6 | #define DPA_HDMI_MUXCTRL (0x1004) 7 | #define DPA_LVDS_MUXCTRL (0x100c) 8 | #define DPA_HDMI_SYNCCTRL0 (0x1014) 9 | #define DPA_HDMI_SYNCCTRL1 (0x1018) 10 | #define DPA_HDMI_SYNCCTRL2 (0x101c) 11 | #define DPA_HDMI_SYNCCTRL3 (0x1020) 12 | #define DPA_TFT_MUXCTRL (0x1024) 13 | 14 | #endif /* __S5P4418_REG_DPA_H__ */ 15 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/s5p4418/reg-i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef __S5P4418_REG_I2C_H__ 2 | #define __S5P4418_REG_I2C_H__ 3 | 4 | #define S5P4418_I2C0_BASE (0xC00A4000) 5 | #define S5P4418_I2C1_BASE (0xC00A5000) 6 | #define S5P4418_I2C2_BASE (0xC00A6000) 7 | 8 | #define I2C_ICCR (0x00) 9 | #define I2C_ICSR (0x04) 10 | #define I2C_IAR (0x08) 11 | #define I2C_IDSR (0x0C) 12 | #define I2C_STOPCON (0x10) 13 | 14 | #endif /* __S5P4418_REG_I2C_H__ */ 15 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/s5p4418/reg-id.h: -------------------------------------------------------------------------------- 1 | #ifndef __S5P4418_REG_ID_H__ 2 | #define __S5P4418_REG_ID_H__ 3 | 4 | #define S5P4418_ID_BASE (0xc0067000) 5 | 6 | #define ID_ECID0 (0x00) 7 | #define ID_ECID1 (0x04) 8 | #define ID_ECID2 (0x08) 9 | #define ID_ECID3 (0x0c) 10 | 11 | #define ID_EC0 (0x54) 12 | #define ID_EC1 (0x58) 13 | #define ID_EC2 (0x5c) 14 | 15 | #endif /* __S5P4418_REG_ID_H__ */ 16 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/s5p4418/reg-rstcon.h: -------------------------------------------------------------------------------- 1 | #ifndef __S5P4418_REG_IP_RSTCON_H__ 2 | #define __S5P4418_REG_IP_RSTCON_H__ 3 | 4 | #define S5P4418_IP_RSTCON_BASE (0xC0012000) 5 | 6 | #define IP_RSTCON0 (0x0) 7 | #define IP_RSTCON1 (0x4) 8 | #define IP_RSTCON2 (0x8) 9 | 10 | #endif /* __S5P4418_REG_IP_RSTCON_H__ */ 11 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/s5p4418/reg-sys.h: -------------------------------------------------------------------------------- 1 | #ifndef __S5P4418_REG_SYS_H__ 2 | #define __S5P4418_REG_SYS_H__ 3 | 4 | #define S5P4418_SYS_CLKMODEREG0 (0xC0010000 + 0x0000) 5 | #define S5P4418_SYS_CLKMODEREG1 (0xC0010000 + 0x0004) 6 | 7 | #define S5P4418_SYS_PLLSETREG0 (0xC0010000 + 0x0008) 8 | #define S5P4418_SYS_PLLSETREG1 (0xC0010000 + 0x000C) 9 | #define S5P4418_SYS_PLLSETREG2 (0xC0010000 + 0x0010) 10 | #define S5P4418_SYS_PLLSETREG3 (0xC0010000 + 0x0014) 11 | 12 | #define S5P4418_SYS_CLKDIVREG0 (0xC0010000 + 0x0020) 13 | #define S5P4418_SYS_CLKDIVREG1 (0xC0010000 + 0x0024) 14 | #define S5P4418_SYS_CLKDIVREG2 (0xC0010000 + 0x0028) 15 | #define S5P4418_SYS_CLKDIVREG3 (0xC0010000 + 0x002C) 16 | #define S5P4418_SYS_CLKDIVREG4 (0xC0010000 + 0x0030) 17 | 18 | #define S5P4418_SYS_PLLSETREG0_SSCG (0xC0010000 + 0x0048) 19 | #define S5P4418_SYS_PLLSETREG1_SSCG (0xC0010000 + 0x004C) 20 | #define S5P4418_SYS_PLLSETREG2_SSCG (0xC0010000 + 0x0050) 21 | #define S5P4418_SYS_PLLSETREG3_SSCG (0xC0010000 + 0x0054) 22 | 23 | #define S5P4418_SYS_GPIOWAKEUPPRISEENB (0xC0010000 + 0x0200) 24 | #define S5P4418_SYS_GPIOWAKEUPFALLENB (0xC0010000 + 0x0204) 25 | #define S5P4418_SYS_GPIORSTENB (0xC0010000 + 0x0208) 26 | #define S5P4418_SYS_GPIOWKENB (0xC0010000 + 0x020C) 27 | #define S5P4418_SYS_GPIOINTENB (0xC0010000 + 0x0210) 28 | #define S5P4418_SYS_GPIOINTPEND (0xC0010000 + 0x0214) 29 | 30 | #define S5P4418_SYS_RESETSTATUS (0xC0010000 + 0x0218) 31 | #define S5P4418_SYS_INTENABLE (0xC0010000 + 0x021C) 32 | #define S5P4418_SYS_INTPEND (0xC0010000 + 0x0220) 33 | #define S5P4418_SYS_PWRCONT (0xC0010000 + 0x0224) 34 | #define S5P4418_SYS_PWRMODE (0xC0010000 + 0x0228) 35 | #define S5P4418_SYS_RSTCONFIG (0xC0010000 + 0x023C) 36 | 37 | #endif /* __S5P4418_REG_WDG_H__ */ 38 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/s5p4418/reg-wdg.h: -------------------------------------------------------------------------------- 1 | #ifndef __S5P4418_REG_WDG_H__ 2 | #define __S5P4418_REG_WDG_H__ 3 | 4 | #define S5P4418_WTCON (0xC0019000 + 0x00) 5 | #define S5P4418_WTDAT (0xC0019000 + 0x04) 6 | #define S5P4418_WTCNT (0xC0019000 + 0x08) 7 | #define S5P4418_WTCLRINT (0xC0019000 + 0x0c) 8 | 9 | #endif /* __S5P4418_REG_WDG_H__ */ 10 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/include/samsung-timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __SAMSUNG_TIMER_H__ 2 | #define __SAMSUNG_TIMER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void samsung_timer_enable(virtual_addr_t virt, int ch, int irqon); 11 | void samsung_timer_disable(virtual_addr_t virt, int ch); 12 | void samsung_timer_start(virtual_addr_t virt, int ch, int oneshot); 13 | void samsung_timer_stop(virtual_addr_t virt, int ch); 14 | u64_t samsung_timer_calc_tin(virtual_addr_t virt, const char * clk, int ch, u32_t period); 15 | void samsung_timer_count(virtual_addr_t virt, int ch, u32_t cnt); 16 | u32_t samsung_timer_read(virtual_addr_t virt, int ch); 17 | void samsung_timer_irq_clear(virtual_addr_t virt, int ch); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif /* __SAMSUNG_TIMER_H__ */ 24 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/images/2ndboot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/images/2ndboot -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-2PCS-1GB.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-2PCS-1GB.xls -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-2PCS-2GB.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-2PCS-2GB.xls -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-4PCS-1GB.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-4PCS-1GB.xls -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-4PCS-2GB.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/images/nsih/NSIH-CPU-800MHZ-DDR3-4PCS-2GB.xls -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/images/nsih/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/images/nsih/README.txt -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/linux/mk4418: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/linux/mk4418 -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/linux/s5p4418-sdmmc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # s5p4418 irom sd/mmc boot fusing tool. 4 | # Author: Jianjun Jiang <8192542@qq.com> 5 | 6 | 7 | # display usage message 8 | USAGE() 9 | { 10 | echo Usage: $(basename "$0") ' ' 11 | echo ' device = disk device name for SD card.' 12 | echo ' bootloader = /path/to/xbootpak.bin' 13 | echo 'e.g. '$(basename "$0")' /dev/sdb xbootpak.bin' 14 | } 15 | 16 | [ `id -u` == 0 ] || { echo "you must be root user"; exit 1; } 17 | [ -z "$1" -o -z "$2" ] && { USAGE; exit 1; } 18 | 19 | dev="$1" 20 | xboot="$2" 21 | 22 | # validate parameters 23 | [ -b "${dev}" ] || { echo "${dev} is not a valid block device"; exit 1; } 24 | [ X"${dev}" = X"${dev%%[0-9]}" ] || { echo "${dev} is a partition, please use device, perhaps ${dev%%[0-9]}"; exit 1; } 25 | [ -f ${xboot} ] || { echo "${xboot} is not a bootloader binary file."; exit 1; } 26 | 27 | # copy the full bootloader image to block device 28 | dd if="${xboot}" of="${dev}" bs=512 seek=1 conv=sync 29 | 30 | sync; 31 | sync; 32 | sync; 33 | 34 | echo "^_^ The image is fused successfully" 35 | 36 | -------------------------------------------------------------------------------- /kernel/arch/arm32/mach-x4418/tools/windows/mk4418.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/kernel/arch/arm32/mach-x4418/tools/windows/mk4418.exe -------------------------------------------------------------------------------- /kernel/arch/arm32/syscalls.c: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #include "unistd.h" 17 | 18 | #define SYSCALL_COMMON(nr,sym) extern unsigned long sym(void); 19 | SYSCALL_COMMON(0, no_system_call) 20 | #include "syscalls.h" 21 | #undef SYSCALL_COMMON 22 | 23 | 24 | #define SYSCALL_COMMON(nr,sym) [nr] = sym, 25 | 26 | 27 | #define MAX_SYSTEM_CALL_NR 128 28 | typedef unsigned long(* system_call_t)(void); 29 | 30 | 31 | system_call_t system_call_table[MAX_SYSTEM_CALL_NR] = { 32 | [0 ... MAX_SYSTEM_CALL_NR - 1] = no_system_call, 33 | #include "syscalls.h" 34 | }; 35 | 36 | -------------------------------------------------------------------------------- /kernel/drivers/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += battery/ 2 | obj-y += block/ 3 | obj-y += buzzer/ 4 | obj-y += clk/ 5 | obj-y += clockevent/ 6 | obj-y += clocksource/ 7 | obj-y += console/ 8 | obj-y += dma/ 9 | obj-y += framebuffer/ 10 | obj-y += gpio/ 11 | obj-y += i2c/ 12 | obj-y += input/ 13 | obj-y += interrupt/ 14 | obj-y += led/ 15 | obj-y += pwm/ 16 | obj-y += regulator/ 17 | obj-y += reset/ 18 | obj-y += rtc/ 19 | obj-y += sd/ 20 | obj-y += uart/ 21 | obj-y += watchdog/ 22 | 23 | -------------------------------------------------------------------------------- /kernel/drivers/block/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += partition/ 2 | obj-y += romdisk/ 3 | obj-y += block.o 4 | obj-y += disk.o 5 | -------------------------------------------------------------------------------- /kernel/drivers/input/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += rc/ 2 | obj-y += input.o 3 | obj-y += key-gpio-polled.o -------------------------------------------------------------------------------- /kernel/fs/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += fat32/ 2 | obj-y += sys/ 3 | obj-y += sys.o 4 | obj-y += vfs.o 5 | obj-y += super.o 6 | obj-y += dcache.o 7 | -------------------------------------------------------------------------------- /kernel/fs/dcache.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | struct dentry *d_alloc(struct dentry *parent, const char *name) 9 | { 10 | struct dentry *path = (struct dentry *)kzalloc(sizeof(struct dentry), 0); 11 | if (!path) 12 | return NULL; 13 | 14 | memset(path, 0, sizeof(struct dentry)); 15 | 16 | init_list_head(&path->child_node); 17 | init_list_head(&path->subdirs_list); 18 | 19 | int len = strlcpy(path->name, name, sizeof(path->name)); 20 | if (len >= sizeof(path->name)) 21 | { 22 | kfree(path); 23 | return NULL; 24 | } 25 | 26 | path->d_parent = parent; 27 | return path; 28 | } 29 | 30 | struct dentry *d_lookup(struct dentry *parent, char *name) 31 | { 32 | struct list_head *i; 33 | 34 | if (!strncmp(name, ".", VFS_MAX_NAME)) 35 | { 36 | return parent; 37 | } 38 | else if (!strncmp(name, "..", VFS_MAX_NAME)) 39 | { 40 | return parent->d_parent; 41 | } 42 | 43 | list_for_each(i, &parent->subdirs_list) 44 | { 45 | struct dentry *temp = container_of(i, struct dentry, child_node); 46 | if (!strncmp(name, temp->name, sizeof(temp->name))) 47 | { 48 | return temp; 49 | } 50 | } 51 | return NULL; 52 | } 53 | 54 | int d_delete(struct dentry *dent) 55 | { 56 | list_del(&dent->child_node); 57 | DELETE(dent->d_inode); 58 | if (dent && !kfree(dent)) 59 | return -1; 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /kernel/fs/super.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static struct super_block *alloc_super(struct filesystem_t *type) 9 | { 10 | struct super_block *s = kzalloc(sizeof(struct super_block), 0); 11 | if (s) { 12 | 13 | } 14 | return s; 15 | } 16 | 17 | 18 | struct super_block *sget(struct filesystem_t *type) 19 | { 20 | struct super_block *s = NULL; 21 | s = alloc_super(type); 22 | if (s) { 23 | } 24 | return s; 25 | } 26 | -------------------------------------------------------------------------------- /kernel/fs/sys.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __SYS_H__ 17 | #define __SYS_H__ 18 | 19 | #define SYSTEM_REBOOT (1UL << 0) 20 | #define SYSTEM_POWEROFF (1UL << 1) 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /kernel/include/aes128.h: -------------------------------------------------------------------------------- 1 | #ifndef __AES128_H__ 2 | #define __AES128_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define AES128_BLOCK_SIZE (16) 11 | 12 | struct aes128_ctx_t { 13 | uint8_t xkey[176]; 14 | }; 15 | 16 | void aes128_set_key(struct aes128_ctx_t * ctx, uint8_t * key); 17 | void aes128_ecb_encrypt(struct aes128_ctx_t * ctx, uint8_t * in, uint8_t * out, int blks); 18 | void aes128_ecb_decrypt(struct aes128_ctx_t * ctx, uint8_t * in, uint8_t * out, int blks); 19 | void aes128_cbc_encrypt(struct aes128_ctx_t * ctx, uint8_t * iv, uint8_t * in, uint8_t * out, int blks); 20 | void aes128_cbc_decrypt(struct aes128_ctx_t * ctx, uint8_t * iv, uint8_t * in, uint8_t * out, int blks); 21 | void aes128_ctr_encrypt(struct aes128_ctx_t * ctx, uint64_t offset, uint8_t * in, uint8_t * out, int bytes); 22 | void aes128_ctr_decrypt(struct aes128_ctx_t * ctx, uint64_t offset, uint8_t * in, uint8_t * out, int bytes); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif /* __AES128_H__ */ 29 | -------------------------------------------------------------------------------- /kernel/include/assert.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASSERT_H__ 2 | #define __ASSERT_H__ 3 | #ifdef NDEBUG 4 | #define assert(test) ((void)0) 5 | #else 6 | void __Assert(char *); 7 | #define _STR(x) _VAR(x) 8 | #define _VAR(x) #x 9 | #define assert(test) ((test)? ((void)0):__Assert(_STR(test)", file: "__FILE__",line: "_STR(__LINE__))) 10 | #endif 11 | #endif -------------------------------------------------------------------------------- /kernel/include/bcd.h: -------------------------------------------------------------------------------- 1 | #ifndef __BCD_H__ 2 | #define __BCD_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | static inline unsigned char bcd2bin(unsigned char x) 9 | { 10 | return (((x) & 0x0f) + ((x) >> 4) * 10); 11 | } 12 | 13 | static inline unsigned char bin2bcd(unsigned char x) 14 | { 15 | return ((((x) / 10) << 4) + (x) % 10); 16 | } 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif /* __BCD_H__ */ 23 | -------------------------------------------------------------------------------- /kernel/include/block.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #pragma once 17 | 18 | struct block_device_operation { 19 | long (*open)(); 20 | long (*close)(); 21 | long (*ioctl)(long cmd, long arg); 22 | long (*transfer)(long cmd, unsigned long blocks, long count, unsigned char * buffer); 23 | }; 24 | 25 | -------------------------------------------------------------------------------- /kernel/include/block/disk.h: -------------------------------------------------------------------------------- 1 | #ifndef __DISK_H__ 2 | #define __DISK_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | struct partition_t 12 | { 13 | /* Partition name */ 14 | char name[64 + 1]; 15 | 16 | /* The sector number of the start */ 17 | u64_t from; 18 | 19 | /* The sector number of the end */ 20 | u64_t to; 21 | 22 | /* The sector's size in bytes */ 23 | u64_t size; 24 | 25 | /* Link to this partition's block device */ 26 | struct block_t * blk; 27 | 28 | /* Link other partition */ 29 | struct list_head entry; 30 | }; 31 | 32 | struct disk_t 33 | { 34 | /* The disk name */ 35 | char * name; 36 | 37 | /* The size of sector */ 38 | u64_t size; 39 | 40 | /* The count of sector */ 41 | u64_t count; 42 | 43 | /* Partition information */ 44 | struct partition_t part; 45 | 46 | /* Read disk device, return the sector counts of reading */ 47 | u64_t (*read)(struct disk_t * disk, u8_t * buf, u64_t sector, u64_t count); 48 | 49 | /* Write disk device, return the sector counts of writing */ 50 | u64_t (*write)(struct disk_t * disk, u8_t * buf, u64_t sector, u64_t count); 51 | 52 | /* Sync cache to disk device */ 53 | void (*sync)(struct disk_t * disk); 54 | 55 | /* Private data */ 56 | void * priv; 57 | }; 58 | 59 | struct disk_t * search_disk(const char * name); 60 | bool_t register_disk(struct device_t ** device, struct disk_t * disk); 61 | bool_t unregister_disk(struct disk_t * disk); 62 | 63 | u64_t disk_read(struct disk_t * disk, u8_t * buf, u64_t offset, u64_t count); 64 | u64_t disk_write(struct disk_t * disk, u8_t * buf, u64_t offset, u64_t count); 65 | void disk_sync(struct disk_t * disk); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* __DISK_H__ */ 72 | -------------------------------------------------------------------------------- /kernel/include/block/partition.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARTITION_H__ 2 | #define __PARTITION_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct partition_map_t 11 | { 12 | struct kobj_t * kobj; 13 | struct list_head list; 14 | char * name; 15 | bool_t (*map)(struct disk_t * disk); 16 | }; 17 | 18 | bool_t register_partition_map(struct partition_map_t * map); 19 | bool_t unregister_partition_map(struct partition_map_t * map); 20 | bool_t partition_map(struct disk_t * disk); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif /* __PARTITION_H__ */ 27 | -------------------------------------------------------------------------------- /kernel/include/bug.h: -------------------------------------------------------------------------------- 1 | #ifndef __BUG_H__ 2 | #define __BUG_H__ 3 | 4 | #include 5 | #include 6 | 7 | #define BUG() do { \ 8 | color_printk(WHITE, RED, "BUG: %s:%d/%s()!", __FILE__, __LINE__, __func__); \ 9 | } while (0) 10 | 11 | #define BUG_ON(condition) do { \ 12 | if (unlikely((condition)!=0)) \ 13 | BUG(); \ 14 | } while(0) 15 | 16 | #define WARN_ON(condition) do{\ 17 | if(unlikely((condition) != 0)) {\ 18 | color_printk(YELLOW, BLACK, "WARN: %s:%d/%s()!", __FILE__, __LINE__, __func__); \ 19 | }\ 20 | }while(0) 21 | 22 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /kernel/include/buzzer/buzzer.h: -------------------------------------------------------------------------------- 1 | #ifndef __BUZZER_H__ 2 | #define __BUZZER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct buzzer_t 11 | { 12 | /* The buzzer name */ 13 | char * name; 14 | 15 | /* Set buzzer's frequency */ 16 | void (*set)(struct buzzer_t * buzzer, int frequency); 17 | 18 | /* Get buzzer's frequency */ 19 | int (*get)(struct buzzer_t * buzzer); 20 | 21 | /* Buzzer beep in with queue, all zero means clear and stop */ 22 | void (*beep)(struct buzzer_t * buzzer, int frequency, int millisecond); 23 | 24 | /* Private data */ 25 | void * priv; 26 | }; 27 | 28 | struct buzzer_t * search_buzzer(const char * name); 29 | struct buzzer_t * search_first_buzzer(void); 30 | bool_t register_buzzer(struct device_t ** device, struct buzzer_t * buzzer); 31 | bool_t unregister_buzzer(struct buzzer_t * buzzer); 32 | 33 | void buzzer_set_frequency(struct buzzer_t * buzzer, int frequency); 34 | int buzzer_get_frequency(struct buzzer_t * buzzer); 35 | void buzzer_beep(struct buzzer_t * buzzer, int frequency, int millisecond); 36 | void buzzer_play(struct buzzer_t * buzzer, const char * rtttl); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __BUZZER_H__ */ 43 | -------------------------------------------------------------------------------- /kernel/include/calls.S: -------------------------------------------------------------------------------- 1 | CALL(sys_open) 2 | CALL(sys_close) 3 | CALL(sys_read) 4 | CALL(sys_write) 5 | CALL(sys_access) 6 | CALL(sys_chdir) 7 | CALL(sys_unlink) 8 | CALL(sys_rename) 9 | CALL(sys_mknod) 10 | CALL(sys_mkdir) 11 | CALL(sys_rmdir) 12 | CALL(sys_getdents) 13 | CALL(sys_stat) 14 | CALL(sys_fstat) 15 | CALL(sys_chown) 16 | CALL(sys_chmod) 17 | CALL(sys_utime) -------------------------------------------------------------------------------- /kernel/include/charset.h: -------------------------------------------------------------------------------- 1 | #ifndef __CHARSET_H__ 2 | #define __CHARSET_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | ssize_t utf8_to_ucs4(u32_t * dst, size_t dsz, const char * src, size_t ssz, const char ** end); 11 | char * ucs4_to_utf8(u32_t * src, size_t ssz, char * dst, size_t dsz); 12 | 13 | ssize_t utf8_to_utf16(u16_t * dst, size_t dsz, const char * src, size_t ssz, const char ** end); 14 | char * utf16_to_utf8(char * dst, u16_t * src, size_t size); 15 | 16 | ssize_t utf8_to_ucs4_alloc(const char * src, u32_t ** dst, u32_t ** pos); 17 | char * ucs4_to_utf8_alloc(u32_t * src, size_t size); 18 | 19 | int ucs4_width(u32_t uc); 20 | size_t utf8_width(const char * s); 21 | 22 | bool_t utf8_is_valid(const char * src, size_t size); 23 | size_t utf8_strlen(const char * s); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* __CHARSET_H__ */ 30 | -------------------------------------------------------------------------------- /kernel/include/clk/clk.h: -------------------------------------------------------------------------------- 1 | #ifndef __CLK_H__ 2 | #define __CLK_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | struct clk_t 12 | { 13 | char * name; 14 | int count; 15 | 16 | void (*set_parent)(struct clk_t * clk, const char * pname); 17 | const char * (*get_parent)(struct clk_t * clk); 18 | void (*set_enable)(struct clk_t * clk, bool_t enable); 19 | bool_t (*get_enable)(struct clk_t * clk); 20 | void (*set_rate)(struct clk_t * clk, u64_t prate, u64_t rate); 21 | u64_t (*get_rate)(struct clk_t * clk, u64_t prate); 22 | 23 | void * priv; 24 | }; 25 | 26 | struct clk_t * search_clk(const char * name); 27 | bool_t register_clk(struct device_t ** device, struct clk_t * clk); 28 | bool_t unregister_clk(struct clk_t * clk); 29 | 30 | void clk_set_parent(const char * name, const char * pname); 31 | const char * clk_get_parent(const char * name); 32 | void clk_enable(const char * name); 33 | void clk_disable(const char * name); 34 | bool_t clk_status(const char * name); 35 | void clk_set_rate(const char * name, u64_t rate); 36 | u64_t clk_get_rate(const char * name); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif /* __CLK_H__ */ 43 | 44 | -------------------------------------------------------------------------------- /kernel/include/command/command.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMMAND_H__ 2 | #define __COMMAND_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | struct command_t 13 | { 14 | struct list_head list; 15 | const char * name; 16 | const char * desc; 17 | 18 | void (*usage)(void); 19 | int (*exec)(int argc, char ** argv); 20 | }; 21 | 22 | extern struct list_head __command_list; 23 | 24 | struct command_t * search_command(const char * name); 25 | bool_t register_command(struct command_t * cmd); 26 | bool_t unregister_command(struct command_t * cmd); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __COMMAND_H__ */ 33 | -------------------------------------------------------------------------------- /kernel/include/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2000-2004 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4 | * 5 | * See file CREDITS for list of people who contributed to this 6 | * project. 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License as 10 | * published by the Free Software Foundation; either version 2 of 11 | * the License, or (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 | * MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef __COMMON_H_ 25 | #define __COMMON_H_ 26 | #include 27 | 28 | #define CONFIG_S3C2440 29 | #define CONFIG_S3C2410 30 | 31 | /* 32 | * General Purpose Utilities 33 | */ 34 | #define min(X, Y) \ 35 | ({ typeof (X) __x = (X), __y = (Y); \ 36 | (__x < __y) ? __x : __y; }) 37 | 38 | #define max(X, Y) \ 39 | ({ typeof (X) __x = (X), __y = (Y); \ 40 | (__x > __y) ? __x : __y; }) 41 | 42 | #endif /* __COMMON_H_ */ 43 | -------------------------------------------------------------------------------- /kernel/include/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPILER_H__ 2 | #define __COMPILER_H__ 3 | 4 | #define __acquire(x) (void)0 5 | #define __release(x) (void)0 6 | 7 | #if (defined(__GNUC__) && (__GNUC__ >= 3)) 8 | #define likely(expr) (__builtin_expect(!!(expr), 1)) 9 | #define unlikely(expr) (__builtin_expect(!!(expr), 0)) 10 | #else 11 | #define likely(expr) (!!(expr)) 12 | #define unlikely(expr) (!!(expr)) 13 | #endif 14 | 15 | /* Optimization barrier */ 16 | #ifndef barrier 17 | # define barrier() __asm__ __volatile__("": : :"memory") 18 | #endif 19 | 20 | /* Unreachable code */ 21 | #ifndef unreachable 22 | # define unreachable() do { } while (1) 23 | #endif 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /kernel/include/console/console.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONSOLE_H__ 2 | #define __CONSOLE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct console_t 11 | { 12 | /* The console name */ 13 | char * name; 14 | 15 | /* Read console */ 16 | ssize_t (*read)(struct console_t * console, unsigned char * buf, size_t count); 17 | 18 | /* Write console */ 19 | ssize_t (*write)(struct console_t * console, const unsigned char * buf, size_t count); 20 | 21 | /* Private data */ 22 | void * priv; 23 | }; 24 | 25 | struct console_t * search_console(const char * name); 26 | struct console_t * search_first_console(void); 27 | bool_t register_console(struct device_t ** device, struct console_t * console); 28 | bool_t unregister_console(struct console_t * console); 29 | 30 | struct console_t * console_get(void); 31 | bool_t console_set(const char * name); 32 | ssize_t console_stdin_read(unsigned char * buf, size_t count); 33 | ssize_t console_stdout_write(const unsigned char * buf, size_t count); 34 | ssize_t console_stderr_write(const unsigned char * buf, size_t count); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif /* __CONSOLE_H__ */ 41 | -------------------------------------------------------------------------------- /kernel/include/core/driver.h: -------------------------------------------------------------------------------- 1 | #ifndef __DRIVER_H__ 2 | #define __DRIVER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | struct device_t; 15 | 16 | struct driver_t 17 | { 18 | struct kobj_t * kobj; 19 | struct hlist_node node; 20 | 21 | char * name; 22 | struct device_t * (*probe)(struct driver_t * drv, struct dtnode_t * dt); 23 | void (*remove)(struct device_t * dev); 24 | void (*suspend)(struct device_t * dev); 25 | void (*resume)(struct device_t * dev); 26 | }; 27 | 28 | struct driver_t * search_driver(const char * name); 29 | bool_t register_driver(struct driver_t * drv); 30 | bool_t unregister_driver(struct driver_t * drv); 31 | void probe_device(const char * json, int length, const char * tips); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* __DRIVER_H__ */ 38 | -------------------------------------------------------------------------------- /kernel/include/core/module.h: -------------------------------------------------------------------------------- 1 | #ifndef __MODULE_H__ 2 | #define __MODULE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define EXPORT_SYMBOL(symbol) 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif /* __MODULE_H__ */ 15 | -------------------------------------------------------------------------------- /kernel/include/core/notifier.h: -------------------------------------------------------------------------------- 1 | #ifndef __NOTIFIER_H__ 2 | #define __NOTIFIER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | struct notifier_t { 13 | struct notifier_t * next; 14 | int priority; 15 | void * data; 16 | int (*call)(struct notifier_t * n, int cmd, void * arg); 17 | }; 18 | 19 | struct notifier_chain_t { 20 | spinlock_t lock; 21 | struct notifier_t * head; 22 | }; 23 | 24 | #define NOTIFIER_CHAIN_INIT() \ 25 | {.lock = SPIN_LOCK_INIT(), .head = NULL} 26 | 27 | void notifier_chain_init(struct notifier_chain_t * nc); 28 | bool_t notifier_chain_register(struct notifier_chain_t * nc, struct notifier_t * n); 29 | bool_t notifier_chain_unregister(struct notifier_chain_t * nc, struct notifier_t * n); 30 | bool_t notifier_chain_call(struct notifier_chain_t * nc, int cmd, void * arg); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* __NOTIFIER_H__ */ 37 | -------------------------------------------------------------------------------- /kernel/include/crc16.h: -------------------------------------------------------------------------------- 1 | #ifndef __CRC16_H__ 2 | #define __CRC16_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | uint16_t crc16_sum(uint16_t crc, const uint8_t * buf, int len); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif /* __CRC16_H__ */ 17 | -------------------------------------------------------------------------------- /kernel/include/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef __CRC32_H__ 2 | #define __CRC32_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | uint32_t crc32_sum(uint32_t crc, const uint8_t * buf, int len); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif /* __CRC32_H__ */ 17 | -------------------------------------------------------------------------------- /kernel/include/crc8.h: -------------------------------------------------------------------------------- 1 | #ifndef __CRC8_H__ 2 | #define __CRC8_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | uint8_t crc8_sum(uint8_t crc, const uint8_t * buf, int len); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif /* __CRC8_H__ */ 17 | -------------------------------------------------------------------------------- /kernel/include/ctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | * NOTE! This ctype does not handle EOF like the standard C 3 | * library is required to. 4 | */ 5 | 6 | #define _U 0x01 /* upper */ 7 | #define _L 0x02 /* lower */ 8 | #define _D 0x04 /* digit */ 9 | #define _C 0x08 /* cntrl */ 10 | #define _P 0x10 /* punct */ 11 | #define _S 0x20 /* white space (space/lf/tab) */ 12 | #define _X 0x40 /* hex digit */ 13 | #define _SP 0x80 /* hard space (0x20) */ 14 | 15 | extern unsigned char _ctype[]; 16 | 17 | #define __ismask(x) (_ctype[(int)(unsigned char)(x)]) 18 | 19 | #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) 20 | #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) 21 | #define iscntrl(c) ((__ismask(c)&(_C)) != 0) 22 | #define isdigit(c) ((__ismask(c)&(_D)) != 0) 23 | #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) 24 | #define islower(c) ((__ismask(c)&(_L)) != 0) 25 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) 26 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) 27 | #define isspace(c) ((__ismask(c)&(_S)) != 0) 28 | #define isupper(c) ((__ismask(c)&(_U)) != 0) 29 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) 30 | 31 | #define isascii(c) (((unsigned char)(c))<=0x7f) 32 | #define toascii(c) (((unsigned char)(c))&0x7f) 33 | 34 | static inline unsigned char __tolower(unsigned char c) 35 | { 36 | if (isupper(c)) 37 | c -= 'A'-'a'; 38 | return c; 39 | } 40 | 41 | static inline unsigned char __toupper(unsigned char c) 42 | { 43 | if (islower(c)) 44 | c -= 'a'-'A'; 45 | return c; 46 | } 47 | 48 | #define tolower(c) __tolower(c) 49 | #define toupper(c) __toupper(c) 50 | -------------------------------------------------------------------------------- /kernel/include/dma/dma.h: -------------------------------------------------------------------------------- 1 | #ifndef __DMA_H__ 2 | #define __DMA_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | enum { 9 | DMA_BIDIRECTIONAL = 0, 10 | DMA_TO_DEVICE = 1, 11 | DMA_FROM_DEVICE = 2, 12 | }; 13 | 14 | void * dma_alloc_coherent(unsigned long size); 15 | void dma_free_coherent(void * addr); 16 | void * dma_alloc_noncoherent(unsigned long size); 17 | void dma_free_noncoherent(void * addr); 18 | void dma_cache_sync(void * addr, unsigned long size, int dir); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif /* __DMA_H__ */ 25 | -------------------------------------------------------------------------------- /kernel/include/fcntl.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __FCNTL_H__ 17 | 18 | #define __FCNTL_H__ 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /kernel/include/fifo.h: -------------------------------------------------------------------------------- 1 | #ifndef __FIFO_H__ 2 | #define __FIFO_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct fifo_t { 11 | unsigned char * buffer; 12 | unsigned int size; 13 | unsigned int in; 14 | unsigned int out; 15 | spinlock_t lock; 16 | }; 17 | 18 | void __fifo_reset(struct fifo_t * f); 19 | unsigned int __fifo_len(struct fifo_t * f); 20 | unsigned int __fifo_put(struct fifo_t * f, unsigned char * buf, unsigned int len); 21 | unsigned int __fifo_get(struct fifo_t * f, unsigned char * buf, unsigned int len); 22 | 23 | struct fifo_t * fifo_alloc(unsigned int size); 24 | void fifo_free(struct fifo_t * f); 25 | void fifo_reset(struct fifo_t * f); 26 | unsigned int fifo_len(struct fifo_t * f); 27 | unsigned int fifo_put(struct fifo_t * f, unsigned char * buf, unsigned int len); 28 | unsigned int fifo_get(struct fifo_t * f, unsigned char * buf, unsigned int len); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* __FIFO_H__ */ 35 | -------------------------------------------------------------------------------- /kernel/include/i2c/i2c-algo-bit.h: -------------------------------------------------------------------------------- 1 | #ifndef __I2C_ALGO_BIT_H__ 2 | #define __I2C_ALGO_BIT_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct i2c_algo_bit_data_t { 11 | void (*setsda)(struct i2c_algo_bit_data_t * data, int state); 12 | void (*setscl)(struct i2c_algo_bit_data_t * data, int state); 13 | int (*getsda)(struct i2c_algo_bit_data_t * data); 14 | int (*getscl)(struct i2c_algo_bit_data_t * data); 15 | /* 16 | * Half clock cycle time in us 17 | * minimum 2 us for fast-mode I2C - 400khz 18 | * minimum 5 us for standard-mode I2C and SMBus - 100khz 19 | * maximum 50 us for SMBus - 10khz 20 | */ 21 | int udelay; 22 | void * priv; 23 | }; 24 | 25 | int i2c_algo_bit_xfer(struct i2c_algo_bit_data_t * bdat, struct i2c_msg_t * msgs, int num); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif /* __I2C_ALGO_BIT_H__ */ 32 | -------------------------------------------------------------------------------- /kernel/include/i2c/i2c.h: -------------------------------------------------------------------------------- 1 | #ifndef __BUS_I2C_H__ 2 | #define __BUS_I2C_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | enum { 11 | I2C_M_TEN = 0x0010, 12 | I2C_M_RD = 0x0001, 13 | I2C_M_STOP = 0x8000, 14 | I2C_M_NOSTART = 0x4000, 15 | I2C_M_REV_DIR_ADDR = 0x2000, 16 | I2C_M_IGNORE_NAK = 0x1000, 17 | I2C_M_NO_RD_ACK = 0x0800, 18 | I2C_M_RECV_LEN = 0x0400, 19 | }; 20 | 21 | struct i2c_msg_t { 22 | int addr; 23 | int flags; 24 | int len; 25 | void * buf; 26 | }; 27 | 28 | struct i2c_t 29 | { 30 | /* The i2c bus name */ 31 | char * name; 32 | 33 | /* Master xfer */ 34 | int (*xfer)(struct i2c_t * i2c, struct i2c_msg_t * msgs, int num); 35 | 36 | /* Private data */ 37 | void * priv; 38 | }; 39 | 40 | struct i2c_device_t { 41 | struct i2c_t * i2c; 42 | int addr; 43 | int flags; 44 | }; 45 | 46 | struct i2c_t * search_i2c(const char * name); 47 | bool_t register_i2c(struct device_t ** device, struct i2c_t * i2c); 48 | bool_t unregister_i2c(struct i2c_t * i2c); 49 | 50 | struct i2c_device_t * i2c_device_alloc(const char * i2cbus, int addr, int flags); 51 | void i2c_device_free(struct i2c_device_t * client); 52 | int i2c_transfer(struct i2c_t * i2c, struct i2c_msg_t * msgs, int num); 53 | int i2c_master_send(const struct i2c_device_t * dev, void * buf, int count); 54 | int i2c_master_recv(const struct i2c_device_t * dev, void * buf, int count); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* __BUS_I2C_H__ */ 61 | -------------------------------------------------------------------------------- /kernel/include/input/input.h: -------------------------------------------------------------------------------- 1 | #ifndef __INPUT_H__ 2 | #define __INPUT_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | enum input_type_t { 11 | INPUT_TYPE_KEYBOARD = 1, 12 | INPUT_TYPE_ROTARY = 2, 13 | INPUT_TYPE_MOUSE = 3, 14 | INPUT_TYPE_TOUCHSCREEN = 4, 15 | INPUT_TYPE_JOYSTICK = 5, 16 | }; 17 | 18 | enum { 19 | INPUT_IOCTL_TOUCHSCEEN_SET_CALIBRATION = 0x00000001, 20 | }; 21 | 22 | struct input_t 23 | { 24 | /* The input name */ 25 | char * name; 26 | 27 | /* Input type */ 28 | enum input_type_t type; 29 | 30 | /* Ioctl interface */ 31 | int (*ioctl)(struct input_t * input, int cmd, void * arg); 32 | 33 | /* Private data */ 34 | void * priv; 35 | }; 36 | 37 | struct input_t * search_input(const char * name); 38 | bool_t register_input(struct device_t ** device, struct input_t * input); 39 | bool_t unregister_input(struct input_t * input); 40 | int input_ioctl(struct input_t * input, int cmd, void * arg); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif /* __INPUT_H__ */ 47 | -------------------------------------------------------------------------------- /kernel/include/input/rc/rc-core.h: -------------------------------------------------------------------------------- 1 | #ifndef __RC_CORE_H__ 2 | #define __RC_CORE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | struct rc_map_t { 13 | uint32_t scancode; 14 | uint32_t keycode; 15 | }; 16 | 17 | struct rc_decoder_t { 18 | struct rc_decoder_nec_t nec; 19 | struct rc_map_t * map; 20 | int size; 21 | }; 22 | 23 | uint32_t rc_decoder_handle(struct rc_decoder_t * decoder, int pulse, int duration); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* __RC_CORE_H__ */ 30 | -------------------------------------------------------------------------------- /kernel/include/input/rc/rc-decoder-nec.h: -------------------------------------------------------------------------------- 1 | #ifndef __RC_DECODER_NEC_H__ 2 | #define __RC_DECODER_NEC_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | enum rc_state_nec_t { 11 | RC_STATE_NEC_INACTIVE = 0, 12 | RC_STATE_NEC_HEADER_SPACE = 1, 13 | RC_STATE_NEC_BIT_PULSE = 2, 14 | RC_STATE_NEC_BIT_SPACE = 3, 15 | RC_STATE_NEC_TRAILER_PULSE = 4, 16 | RC_STATE_NEC_TRAILER_SPACE = 5, 17 | }; 18 | 19 | struct rc_decoder_nec_t { 20 | enum rc_state_nec_t state; 21 | uint32_t bits; 22 | int count; 23 | int repeat; 24 | }; 25 | 26 | uint32_t rc_nec_decoder_handle(struct rc_decoder_nec_t * decoder, int pulse, int duration); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __RC_DECODER_NEC_H__ */ 33 | -------------------------------------------------------------------------------- /kernel/include/interrupt/interrupt.h: -------------------------------------------------------------------------------- 1 | #ifndef __INTERRUPT_H__ 2 | #define __INTERRUPT_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | enum irq_type_t { 11 | IRQ_TYPE_NONE = 0, 12 | IRQ_TYPE_LEVEL_LOW = 1, 13 | IRQ_TYPE_LEVEL_HIGH = 2, 14 | IRQ_TYPE_EDGE_FALLING = 3, 15 | IRQ_TYPE_EDGE_RISING = 4, 16 | IRQ_TYPE_EDGE_BOTH = 5, 17 | }; 18 | 19 | struct irq_handler_t { 20 | void (*func)(void * data); 21 | void * data; 22 | }; 23 | 24 | struct irqchip_t 25 | { 26 | char * name; 27 | int base; 28 | int nirq; 29 | 30 | struct irq_handler_t * handler; 31 | void (*enable)(struct irqchip_t * chip, int offset); 32 | void (*disable)(struct irqchip_t * chip, int offset); 33 | void (*settype)(struct irqchip_t * chip, int offset, enum irq_type_t type); 34 | void (*dispatch)(struct irqchip_t * chip); 35 | 36 | void * priv; 37 | }; 38 | 39 | bool_t register_irqchip(struct device_t ** device, struct irqchip_t * chip); 40 | bool_t unregister_irqchip(struct irqchip_t * chip); 41 | bool_t register_sub_irqchip(struct device_t ** device, int parent, struct irqchip_t * chip); 42 | bool_t unregister_sub_irqchip(int parent, struct irqchip_t * chip); 43 | bool_t irq_is_valid(int irq); 44 | bool_t request_irq(int irq, void (*func)(void *), enum irq_type_t type, void * data); 45 | bool_t free_irq(int irq); 46 | void enable_irq(int irq); 47 | void disable_irq(int irq); 48 | void interrupt_handle_exception(void * regs); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif /* __INTERRUPT_H__ */ 55 | -------------------------------------------------------------------------------- /kernel/include/io.h: -------------------------------------------------------------------------------- 1 | #ifndef __IO_H__ 2 | #define __IO_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | static inline u8_t read8(virtual_addr_t addr) 11 | { 12 | return( *((volatile u8_t *)(addr)) ); 13 | } 14 | 15 | static inline u16_t read16(virtual_addr_t addr) 16 | { 17 | return( *((volatile u16_t *)(addr)) ); 18 | } 19 | 20 | static inline u32_t read32(virtual_addr_t addr) 21 | { 22 | return( *((volatile u32_t *)(addr)) ); 23 | } 24 | 25 | static inline u64_t read64(virtual_addr_t addr) 26 | { 27 | return( *((volatile u64_t *)(addr)) ); 28 | } 29 | 30 | static inline void write8(virtual_addr_t addr, u8_t value) 31 | { 32 | *((volatile u8_t *)(addr)) = value; 33 | } 34 | 35 | static inline void write16(virtual_addr_t addr, u16_t value) 36 | { 37 | *((volatile u16_t *)(addr)) = value; 38 | } 39 | 40 | static inline void write32(virtual_addr_t addr, u32_t value) 41 | { 42 | *((volatile u32_t *)(addr)) = value; 43 | } 44 | 45 | static inline void write64(virtual_addr_t addr, u64_t value) 46 | { 47 | *((volatile u64_t *)(addr)) = value; 48 | } 49 | 50 | virtual_addr_t phys_to_virt(physical_addr_t phys); 51 | physical_addr_t virt_to_phys(virtual_addr_t virt); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif /* __IO_H__ */ 58 | -------------------------------------------------------------------------------- /kernel/include/json.h: -------------------------------------------------------------------------------- 1 | #ifndef __JSON_H__ 2 | #define __JSON_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | struct json_value_t; 12 | struct json_object_entry_t; 13 | 14 | enum json_type_t { 15 | JSON_NONE = 0, 16 | JSON_OBJECT = 1, 17 | JSON_ARRAY = 2, 18 | JSON_INTEGER = 3, 19 | JSON_DOUBLE = 4, 20 | JSON_STRING = 5, 21 | JSON_BOOLEAN = 6, 22 | JSON_NULL = 7, 23 | }; 24 | 25 | struct json_value_t { 26 | struct json_value_t * parent; 27 | enum json_type_t type; 28 | 29 | union { 30 | int boolean; 31 | int64_t integer; 32 | double dbl; 33 | 34 | struct { 35 | unsigned int length; 36 | char * ptr; 37 | } string; 38 | 39 | struct { 40 | unsigned int length; 41 | struct json_object_entry_t * values; 42 | } object; 43 | 44 | struct { 45 | unsigned int length; 46 | struct json_value_t ** values; 47 | } array; 48 | } u; 49 | 50 | union { 51 | struct json_value_t * next_alloc; 52 | void * object_mem; 53 | } reserved; 54 | }; 55 | 56 | struct json_object_entry_t { 57 | char * name; 58 | unsigned int name_length; 59 | struct json_value_t * value; 60 | }; 61 | 62 | struct json_value_t * json_parse(const char * json, size_t length, char * errbuf); 63 | void json_free(struct json_value_t * value); 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif /* __JSON_H__ */ 70 | -------------------------------------------------------------------------------- /kernel/include/kconfigs.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define CONFIG_DRIVER_HASH_SIZE (257) 4 | #define CONFIG_DEVICE_HASH_SIZE (257) 5 | #define CONFIG_MAX_BRIGHTNESS (1000) 6 | #define CONFIG_EVENT_FIFO_LENGTH (8) 7 | -------------------------------------------------------------------------------- /kernel/include/kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef _KERNEL_H 2 | #define _KERNEL_H 3 | 4 | #define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) 5 | #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) 6 | #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) 7 | 8 | #ifndef ARRAY_SIZE 9 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /kernel/include/ldscript.h: -------------------------------------------------------------------------------- 1 | #ifndef __LDSCRIPT_H__ 2 | #define __LDSCRIPT_H__ 3 | 4 | extern char __text_start; 5 | extern char __text_end; 6 | extern char __data_start; 7 | extern char __data_end; 8 | extern char __rodata_start; 9 | extern char __rodata_end; 10 | extern char __bss_start; 11 | extern char __bss_end; 12 | extern char __end; 13 | extern char __heap_start; 14 | extern char __heap_end; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /kernel/include/led/led.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_H__ 2 | #define __LED_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct led_t 11 | { 12 | /* The LED name */ 13 | char * name; 14 | 15 | /* Set LED's brightness (0 ~ CONFIG_MAX_BRIGHTNESS) */ 16 | void (*set)(struct led_t * led, int brightness); 17 | 18 | /* Get LED's brightness */ 19 | int (*get)(struct led_t * led); 20 | 21 | /* Private data */ 22 | void * priv; 23 | }; 24 | 25 | struct led_t * search_led(const char * name); 26 | bool_t register_led(struct device_t ** device, struct led_t * led); 27 | bool_t unregister_led(struct led_t * led); 28 | 29 | void led_set_brightness(struct led_t * led, int brightness); 30 | int led_get_brightness(struct led_t * led); 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif /* __LED_H__ */ 37 | -------------------------------------------------------------------------------- /kernel/include/led/ledstrip.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_STRIP_H__ 2 | #define __LED_STRIP_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct ledstrip_t 11 | { 12 | char * name; 13 | 14 | void (*set_count)(struct ledstrip_t * strip, int c); 15 | int (*get_count)(struct ledstrip_t * strip); 16 | void (*set_color)(struct ledstrip_t * strip, int i, uint32_t color); 17 | uint32_t (*get_color)(struct ledstrip_t * strip, int i); 18 | void (*refresh)(struct ledstrip_t * strip); 19 | 20 | void * priv; 21 | }; 22 | 23 | struct ledstrip_t * search_ledstrip(const char * name); 24 | bool_t register_ledstrip(struct device_t ** device, struct ledstrip_t * strip); 25 | bool_t unregister_ledstrip(struct ledstrip_t * strip); 26 | 27 | void ledstrip_set_count(struct ledstrip_t * strip, int c); 28 | int ledstrip_get_count(struct ledstrip_t * strip); 29 | void ledstrip_set_color(struct ledstrip_t * strip, int i, uint32_t color); 30 | uint32_t ledstrip_get_color(struct ledstrip_t * strip, int i); 31 | void ledstrip_refresh(struct ledstrip_t * strip); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* __LED_STRIP_H__ */ 38 | -------------------------------------------------------------------------------- /kernel/include/led/ledtrigger.h: -------------------------------------------------------------------------------- 1 | #ifndef __LED_TRIGGER_H__ 2 | #define __LED_TRIGGER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct ledtrigger_t 11 | { 12 | /* The led trigger name */ 13 | char * name; 14 | 15 | /* Activity led trigger */ 16 | void (*activity)(struct ledtrigger_t * trigger); 17 | 18 | /* Private data */ 19 | void * priv; 20 | }; 21 | 22 | struct ledtrigger_t * search_ledtrigger(const char * name); 23 | bool_t register_ledtrigger(struct device_t ** device, struct ledtrigger_t * trigger); 24 | bool_t unregister_ledtrigger(struct ledtrigger_t * trigger); 25 | 26 | void ledtrigger_activity(struct ledtrigger_t * trigger); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __LED_TRIGGER_H__ */ 33 | -------------------------------------------------------------------------------- /kernel/include/linkage.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINKAGE_H_ 2 | #define _LINKAGE_H_ 3 | 4 | #define L1_CACHE_BYTES 32 5 | #define asmlinkage __attribute__((regparm(0))) 6 | #define ____cacheline_aligned __attribute__((__aligned__(L1_CACHE_BYTES))) 7 | 8 | #define __ALIGN .align 0 9 | #define __ALIGN_STR ".align 0" 10 | 11 | #define ALIGN __ALIGN 12 | #define ALIGN_STR __ALIGN_STR 13 | 14 | #ifndef ENTRY 15 | #define ENTRY(name) \ 16 | .globl name; \ 17 | ALIGN; \ 18 | name: 19 | #endif 20 | 21 | #ifndef WEAK 22 | #define WEAK(name) \ 23 | .weak name; \ 24 | name: 25 | #endif 26 | 27 | #ifndef END 28 | #define END(name) \ 29 | .size name, .-name 30 | #endif 31 | 32 | /* If symbol 'name' is treated as a subroutine (gets called, and returns) 33 | * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of 34 | * static analysis tools such as stack depth analyzer. 35 | */ 36 | 37 | #define ENDPROC(name) \ 38 | .type name, %function; \ 39 | END(name) 40 | 41 | #define ARM(x...) x 42 | #define THUMB(x...) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /kernel/include/malloc.h: -------------------------------------------------------------------------------- 1 | #ifndef __MALLOC_H__ 2 | #define __MALLOC_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void * malloc(size_t size); 11 | void * memalign(size_t align, size_t size); 12 | void * realloc(void * ptr, size_t size); 13 | void * calloc(size_t nmemb, size_t size); 14 | void free(void * ptr); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif /* __MATH_H__ */ 21 | -------------------------------------------------------------------------------- /kernel/include/mm_types.h: -------------------------------------------------------------------------------- 1 | #ifndef __MM_TYPES_H__ 2 | #define __MM_TYPES_H__ 3 | 4 | #include 5 | #include 6 | 7 | struct vm_area_struct { 8 | 9 | }; 10 | 11 | struct mm_struct { 12 | pgd_t *pgd; //page table point 13 | 14 | unsigned long start_code, end_code; 15 | unsigned long start_data, end_data; 16 | unsigned long start_rodata, end_rodata; 17 | unsigned long start_bss, end_bss; 18 | unsigned long start_brk, end_brk; 19 | unsigned long start_stack; 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /kernel/include/pgtable-2level-types.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_PGTABLE_2LEVEL_TYPES_H 2 | #define _ASM_PGTABLE_2LEVEL_TYPES_H 3 | 4 | #include 5 | 6 | typedef u32 pteval_t; 7 | typedef u32 pmdval_t; 8 | 9 | typedef pteval_t pte_t; 10 | typedef pmdval_t pmd_t; 11 | typedef pmdval_t pgd_t[2]; 12 | typedef pteval_t pgprot_t; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /kernel/include/pgtable.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASMARM_PGTABLE_H 2 | #define _ASMARM_PGTABLE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | typedef u32 phys_addr_t; 10 | 11 | static inline void set_pte_ext(pte_t *ptep, pte_t pte){ 12 | *ptep = pte; 13 | flush_pmd_entry(ptep); 14 | } 15 | 16 | #define ARCH_PFN_OFFSET 0 17 | 18 | #define pfn_to_page(pfn) (mem_map + ((pfn) - ARCH_PFN_OFFSET)) 19 | #define page_to_pfn(page) ((unsigned long)((page) - mem_map) + ARCH_PFN_OFFSET) 20 | 21 | #define __phys_to_pfn(paddr) ((unsigned long)((paddr) >> PAGE_SHIFT)) 22 | #define __pfn_to_phys(pfn) ((phys_addr_t)(pfn) << PAGE_SHIFT) 23 | 24 | 25 | #define pfn_pte(pfn,prot) (__pfn_to_phys(pfn) | (prot)) 26 | 27 | /* to find an entry in a page-table-directory */ 28 | #define pgd_index(addr) ((addr) >> PGDIR_SHIFT) 29 | #define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr)) 30 | #define mk_pgd(page,prot) pfn_pte(page_to_pfn(page), prot) 31 | 32 | #define pte_index(addr) (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 33 | #define mk_pte(page,prot) pfn_pte(page_to_pfn(page), prot) 34 | #define pte_clear(mm,addr,ptep) set_pte_ext(ptep, 0, 0) 35 | 36 | #define copy_pmd(pmdpd,pmdps) \ 37 | do { \ 38 | pmdpd[0] = pmdps[0]; \ 39 | pmdpd[1] = pmdps[1]; \ 40 | flush_pmd_entry(pmdpd); \ 41 | } while (0) 42 | 43 | #define pmd_clear(pmdp) \ 44 | do { \ 45 | pmdp[0] = 0; \ 46 | pmdp[1] = 0; \ 47 | clean_pmd_entry(pmdp); \ 48 | } while (0) 49 | #endif 50 | -------------------------------------------------------------------------------- /kernel/include/pgtable_2level.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_PGTABLE_2LEVEL_H 2 | #define _ASM_PGTABLE_2LEVEL_H 3 | 4 | #define PTRS_PER_PTE 512 5 | #define PTRS_PER_PMD 1 6 | #define PTRS_PER_PGD 2048 7 | 8 | #define PTE_HWTABLE_PTRS (PTRS_PER_PTE) 9 | #define PTE_HWTABLE_OFF (PTE_HWTABLE_PTRS * sizeof(pte_t)) 10 | #define PTE_HWTABLE_SIZE (PTRS_PER_PTE * sizeof(u32)) 11 | 12 | /* 13 | * PMD_SHIFT determines the size of the area a second-level page table can map 14 | * PGDIR_SHIFT determines what a third-level page table entry can map 15 | */ 16 | #define PMD_SHIFT 21 17 | #define PGDIR_SHIFT 21 18 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 19 | 20 | #define PMD_SIZE (1UL << PMD_SHIFT) 21 | #define PMD_MASK (~(PMD_SIZE-1)) 22 | #define PGDIR_SIZE (1UL << PGDIR_SHIFT) 23 | #define PGDIR_MASK (~(PGDIR_SIZE-1)) 24 | 25 | /* 26 | * section address mask and size definitions. 27 | */ 28 | #define SECTION_SHIFT 20 29 | #define SECTION_SIZE (1UL << SECTION_SHIFT) 30 | #define SECTION_MASK (~(SECTION_SIZE-1)) 31 | 32 | /* PAGE_SHIFT determines the page size */ 33 | #define PAGE_SHIFT 12 34 | #define PAGE_SIZE (1UL << PAGE_SHIFT) 35 | #define PAGE_MASK (~(PAGE_SIZE-1)) 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /kernel/include/preempt.h: -------------------------------------------------------------------------------- 1 | #ifndef __PREEMPT_H__ 2 | #define __PREEMPT_H__ 3 | 4 | #include 5 | 6 | #if 1 7 | extern void add_preempt_count(int val); 8 | extern void sub_preempt_count(int val); 9 | extern long preempt_count(); 10 | 11 | #else 12 | 13 | #define preempt_count() (current->preempt_count) 14 | 15 | #define add_preempt_count(val) do { preempt_count() += (val); } while (0) 16 | #define sub_preempt_count(val) do { preempt_count() -= (val); } while (0) 17 | 18 | #endif 19 | #define inc_preempt_count() add_preempt_count(1) 20 | #define dec_preempt_count() sub_preempt_count(1) 21 | 22 | //TODO:完善 23 | //#ifdef CONFIG_PREEMPT_COUNT 24 | #if 1 25 | 26 | #define preempt_disable() \ 27 | do { \ 28 | inc_preempt_count(); \ 29 | barrier(); \ 30 | } while (0) 31 | #define sched_preempt_enable_no_resched() \ 32 | do { \ 33 | barrier(); \ 34 | dec_preempt_count(); \ 35 | } while (0) 36 | 37 | #define preempt_enable_no_resched() sched_preempt_enable_no_resched() 38 | 39 | #define preempt_enable() \ 40 | do { \ 41 | preempt_enable_no_resched(); \ 42 | barrier(); \ 43 | } while (0) 44 | 45 | #else 46 | 47 | #define preempt_disable() do { } while (0) 48 | #define sched_preempt_enable_no_resched() do { } while (0) 49 | #define preempt_enable_no_resched() do { } while (0) 50 | #define preempt_enable() do { } while (0) 51 | 52 | #endif 53 | #endif 54 | -------------------------------------------------------------------------------- /kernel/include/pwm/pwm.h: -------------------------------------------------------------------------------- 1 | #ifndef __PWM_H__ 2 | #define __PWM_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct pwm_t 11 | { 12 | char * name; 13 | 14 | int __enable; 15 | int __duty; 16 | int __period; 17 | int __polarity; 18 | 19 | void (*config)(struct pwm_t * pwm, int duty, int period, int polarity); 20 | void (*enable)(struct pwm_t * pwm); 21 | void (*disable)(struct pwm_t * pwm); 22 | 23 | void * priv; 24 | }; 25 | 26 | struct pwm_t * search_pwm(const char * name); 27 | bool_t register_pwm(struct device_t ** device, struct pwm_t * pwm); 28 | bool_t unregister_pwm(struct pwm_t * pwm); 29 | 30 | void pwm_config(struct pwm_t * pwm, int duty, int period, int polarity); 31 | void pwm_enable(struct pwm_t * pwm); 32 | void pwm_disable(struct pwm_t * pwm); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* __PWM_H__ */ 39 | -------------------------------------------------------------------------------- /kernel/include/queue.h: -------------------------------------------------------------------------------- 1 | #ifndef __QUEUE_H__ 2 | #define __QUEUE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | struct queue_node_t { 12 | struct list_head entry; 13 | void * data; 14 | }; 15 | 16 | struct queue_t 17 | { 18 | struct queue_node_t node; 19 | spinlock_t lock; 20 | int available; 21 | }; 22 | 23 | struct queue_t * queue_alloc(void); 24 | void queue_free(struct queue_t * q, void (*iter)(struct queue_node_t *)); 25 | void queue_clear(struct queue_t * q, void (*iter)(struct queue_node_t *)); 26 | int queue_avail(struct queue_t * q); 27 | void queue_push(struct queue_t * q, void * data); 28 | void * queue_pop(struct queue_t * q); 29 | void * queue_peek(struct queue_t * q); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif /* __QUEUE_H__ */ 36 | -------------------------------------------------------------------------------- /kernel/include/regulator/regulator.h: -------------------------------------------------------------------------------- 1 | #ifndef __REGULATOR_H__ 2 | #define __REGULATOR_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct regulator_t 11 | { 12 | char * name; 13 | int count; 14 | 15 | void (*set_parent)(struct regulator_t * supply, const char * pname); 16 | const char * (*get_parent)(struct regulator_t * supply); 17 | void (*set_enable)(struct regulator_t * supply, bool_t enable); 18 | bool_t (*get_enable)(struct regulator_t * supply); 19 | void (*set_voltage)(struct regulator_t * supply, int voltage); 20 | int (*get_voltage)(struct regulator_t * supply); 21 | 22 | void * priv; 23 | }; 24 | 25 | struct regulator_t * search_regulator(const char * name); 26 | bool_t register_regulator(struct device_t ** device, struct regulator_t * supply); 27 | bool_t unregister_regulator(struct regulator_t * supply); 28 | 29 | void regulator_set_parent(const char * name, const char * pname); 30 | const char * regulator_get_parent(const char * name); 31 | void regulator_enable(const char * name); 32 | void regulator_disable(const char * name); 33 | bool_t regulator_status(const char * name); 34 | void regulator_set_voltage(const char * name, int voltage); 35 | int regulator_get_voltage(const char * name); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __REGULATOR_H__ */ 42 | 43 | -------------------------------------------------------------------------------- /kernel/include/reset/reset.h: -------------------------------------------------------------------------------- 1 | #ifndef __RESET_H__ 2 | #define __RESET_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct resetchip_t 11 | { 12 | char * name; 13 | int base; 14 | int nreset; 15 | 16 | void (*assert)(struct resetchip_t * chip, int offset); 17 | void (*deassert)(struct resetchip_t * chip, int offset); 18 | 19 | void * priv; 20 | }; 21 | 22 | struct resetchip_t * search_resetchip(int rst); 23 | bool_t register_resetchip(struct device_t ** device, struct resetchip_t * chip); 24 | bool_t unregister_resetchip(struct resetchip_t * chip); 25 | 26 | int reset_is_valid(int rst); 27 | void reset_assert(int rst); 28 | void reset_deassert(int rst); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif /* __RESET_H__ */ 35 | -------------------------------------------------------------------------------- /kernel/include/rtc/rtc.h: -------------------------------------------------------------------------------- 1 | #ifndef __RTC_H__ 2 | #define __RTC_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct rtc_time_t { 11 | u8_t second; 12 | u8_t minute; 13 | u8_t hour; 14 | u8_t week; 15 | u8_t day; 16 | u8_t month; 17 | u16_t year; 18 | }; 19 | 20 | struct rtc_t 21 | { 22 | /* The rtc name */ 23 | char * name; 24 | 25 | /* Set rtc time */ 26 | bool_t (*settime)(struct rtc_t * rtc, struct rtc_time_t * time); 27 | 28 | /* Get rtc time */ 29 | bool_t (*gettime)(struct rtc_t * rtc, struct rtc_time_t * time); 30 | 31 | /* Private data */ 32 | void * priv; 33 | }; 34 | 35 | struct rtc_t * search_rtc(const char * name); 36 | struct rtc_t * search_first_rtc(void); 37 | bool_t register_rtc(struct device_t ** device, struct rtc_t * rtc); 38 | bool_t unregister_rtc(struct rtc_t * rtc); 39 | 40 | bool_t rtc_settime(struct rtc_t * rtc, struct rtc_time_t * time); 41 | bool_t rtc_gettime(struct rtc_t * rtc, struct rtc_time_t * time); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif /* __RTC_H__ */ 48 | -------------------------------------------------------------------------------- /kernel/include/schedule.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __SCHEDULE_H__ 17 | #define __SCHEDULE_H__ 18 | 19 | #include "task.h" 20 | 21 | struct scheduler_t { 22 | struct rb_root_cached ready; 23 | struct list_head suspend; 24 | struct task_t * running; 25 | uint64_t min_vtime; 26 | uint64_t weight; 27 | spinlock_t lock; 28 | }; 29 | 30 | extern struct scheduler_t __sched[NR_CPUS]; 31 | 32 | void schedule(); 33 | void do_init_sched(); 34 | 35 | struct task_t * task_create(struct scheduler_t * sched, const char * name, size_t stksz, int nice); 36 | void task_destroy(struct task_t * task); 37 | void task_zombie(struct task_t * task); 38 | void task_renice(struct task_t * task, int nice); 39 | void task_suspend(struct task_t * task); 40 | void task_resume(struct task_t * task); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /kernel/include/sd/sdcard.h: -------------------------------------------------------------------------------- 1 | #ifndef __SDCARD_H__ 2 | #define __SDCARD_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void * sdcard_probe(struct sdhci_t * hci); 11 | void sdcard_remove(void * card); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif /* __SDCARD_H__ */ 18 | -------------------------------------------------------------------------------- /kernel/include/sd/sdhci.h: -------------------------------------------------------------------------------- 1 | #ifndef __SDHCI_H__ 2 | #define __SDHCI_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | struct sdhci_cmd_t { 12 | u32_t cmdidx; 13 | u32_t cmdarg; 14 | u32_t resptype; 15 | u32_t response[4]; 16 | }; 17 | 18 | struct sdhci_data_t { 19 | u8_t * buf; 20 | u32_t flag; 21 | u32_t blksz; 22 | u32_t blkcnt; 23 | }; 24 | 25 | struct sdhci_t 26 | { 27 | char * name; 28 | u32_t voltage; 29 | u32_t width; 30 | u32_t clock; 31 | bool_t removable; 32 | bool_t isspi; 33 | void * sdcard; 34 | 35 | bool_t (*detect)(struct sdhci_t * hci); 36 | bool_t (*setvoltage)(struct sdhci_t * hci, u32_t voltage); 37 | bool_t (*setwidth)(struct sdhci_t * hci, u32_t width); 38 | bool_t (*setclock)(struct sdhci_t * hci, u32_t clock); 39 | bool_t (*transfer)(struct sdhci_t * hci, struct sdhci_cmd_t * cmd, struct sdhci_data_t * dat); 40 | void * priv; 41 | }; 42 | 43 | struct sdhci_t * search_sdhci(const char * name); 44 | bool_t register_sdhci(struct device_t ** device, struct sdhci_t * hci); 45 | bool_t unregister_sdhci(struct sdhci_t * hci); 46 | 47 | bool_t sdhci_detect(struct sdhci_t * hci); 48 | bool_t sdhci_set_voltage(struct sdhci_t * hci, u32_t voltage); 49 | bool_t sdhci_set_width(struct sdhci_t * hci, u32_t width); 50 | bool_t sdhci_set_clock(struct sdhci_t * hci, u32_t clock); 51 | bool_t sdhci_transfer(struct sdhci_t * hci, struct sdhci_cmd_t * cmd, struct sdhci_data_t * dat); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif /* __SDHCI_H__ */ 58 | -------------------------------------------------------------------------------- /kernel/include/semaphore.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __SEMAPHORE_H__ 17 | 18 | #define __SEMAPHORE_H__ 19 | 20 | #include "atomic.h" 21 | #include "lib.h" 22 | #include "task.h" 23 | #include "schedule.h" 24 | #include "waitqueue.h" 25 | 26 | typedef struct { 27 | atomic_T counter; 28 | wait_queue_t wait; 29 | } semaphore_T; 30 | 31 | void semaphore_init(semaphore_T * semaphore, unsigned long count); 32 | 33 | void semaphore_up(semaphore_T * semaphore); 34 | 35 | void semaphore_down(semaphore_T * semaphore); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /kernel/include/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHA1_H__ 2 | #define __SHA1_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define SHA1_DIGEST_SIZE (20) 11 | 12 | struct sha1_ctx_t { 13 | uint64_t count; 14 | uint8_t buf[64]; 15 | uint32_t state[5]; 16 | }; 17 | 18 | void sha1_init(struct sha1_ctx_t * ctx); 19 | void sha1_update(struct sha1_ctx_t * ctx, const void * data, int len); 20 | const uint8_t * sha1_final(struct sha1_ctx_t * ctx); 21 | const uint8_t * sha1_hash(const void * data, int len, uint8_t * digest); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif /* __SHA1_H__ */ 28 | -------------------------------------------------------------------------------- /kernel/include/sha256.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHA256_H__ 2 | #define __SHA256_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define SHA256_DIGEST_SIZE (32) 11 | 12 | struct sha256_ctx_t { 13 | uint64_t count; 14 | uint8_t buf[64]; 15 | uint32_t state[8]; 16 | }; 17 | 18 | void sha256_init(struct sha256_ctx_t * ctx); 19 | void sha256_update(struct sha256_ctx_t * ctx, const void * data, int len); 20 | const uint8_t * sha256_final(struct sha256_ctx_t * ctx); 21 | const uint8_t * sha256_hash(const void * data, int len, uint8_t * digest); 22 | 23 | #ifdef __cplusplus 24 | } 25 | #endif 26 | 27 | #endif /* __SHA256_H__ */ 28 | -------------------------------------------------------------------------------- /kernel/include/shell/ctrlc.h: -------------------------------------------------------------------------------- 1 | #ifndef __CTRLC_H__ 2 | #define __CTRLC_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | int ctrlc(void); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif /* __CTRLC_H__ */ 15 | -------------------------------------------------------------------------------- /kernel/include/shell/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef __PARSER_H__ 2 | #define __PARSER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | bool_t parser(const char * cmdline, int * argc, char *** argv, char ** pos); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif /* __PARSER_H__ */ 17 | -------------------------------------------------------------------------------- /kernel/include/shell/readline.h: -------------------------------------------------------------------------------- 1 | #ifndef __READLINE_H__ 2 | #define __READLINE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | char * readline(const char * prompt); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif /* __READLINE_H__ */ 15 | -------------------------------------------------------------------------------- /kernel/include/shell/shell.h: -------------------------------------------------------------------------------- 1 | #ifndef __SHELL_H__ 2 | #define __SHELL_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | int shell_realpath(const char * path, char * fpath); 11 | const char * shell_getcwd(void); 12 | int shell_setcwd(const char * path); 13 | int shell_system(const char * cmdline); 14 | void shell_task(struct task_t * task, void * data); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif /* __SHELL_H__ */ 21 | -------------------------------------------------------------------------------- /kernel/include/sizes.h: -------------------------------------------------------------------------------- 1 | #ifndef __SIZES_H__ 2 | #define __SIZES_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define SZ_16 (0x00000010) 9 | #define SZ_256 (0x00000100) 10 | #define SZ_512 (0x00000200) 11 | 12 | #define SZ_1K (0x00000400) 13 | #define SZ_4K (0x00001000) 14 | #define SZ_8K (0x00002000) 15 | #define SZ_16K (0x00004000) 16 | #define SZ_32K (0x00008000) 17 | #define SZ_64K (0x00010000) 18 | #define SZ_128K (0x00020000) 19 | #define SZ_256K (0x00040000) 20 | #define SZ_512K (0x00080000) 21 | 22 | #define SZ_1M (0x00100000) 23 | #define SZ_2M (0x00200000) 24 | #define SZ_4M (0x00400000) 25 | #define SZ_8M (0x00800000) 26 | #define SZ_16M (0x01000000) 27 | #define SZ_32M (0x02000000) 28 | #define SZ_64M (0x04000000) 29 | #define SZ_128M (0x08000000) 30 | #define SZ_256M (0x10000000) 31 | #define SZ_512M (0x20000000) 32 | 33 | #define SZ_1G (0x40000000) 34 | #define SZ_2G (0x80000000) 35 | 36 | #ifndef ARRAY_SIZE 37 | #define ARRAY_SIZE(array) ( sizeof(array) / sizeof((array)[0]) ) 38 | #endif 39 | 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* __SIZES_H__ */ 46 | -------------------------------------------------------------------------------- /kernel/include/slist.h: -------------------------------------------------------------------------------- 1 | #ifndef __SLIST_H__ 2 | #define __SLIST_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | struct slist_t { 12 | struct list_head list; 13 | char * key; 14 | void * priv; 15 | }; 16 | 17 | #define slist_for_each_entry(entry, sl) \ 18 | list_for_each_entry(entry, &(sl)->list, list) 19 | 20 | struct slist_t * slist_alloc(void); 21 | void slist_free(struct slist_t * sl); 22 | void slist_add(struct slist_t * sl, void * priv, const char * fmt, ...); 23 | void slist_sort(struct slist_t * sl); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif /* __SLIST_H__ */ 30 | -------------------------------------------------------------------------------- /kernel/include/softirq.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __SOFTIRQ_H__ 17 | #define __SOFTIRQ_H__ 18 | 19 | #include 20 | 21 | #define TIMER_SIRQ (1 << 0) 22 | 23 | extern unsigned long softirq_status; 24 | 25 | struct softirq { 26 | void (*action)(void * data); 27 | void * data; 28 | }; 29 | 30 | extern struct softirq softirq_vector[BITS_PER_LONG]; 31 | 32 | 33 | void register_softirq(int nr, void (*action)(void * data), void * data); 34 | void unregister_softirq(int nr); 35 | 36 | void set_softirq_status(unsigned long status); 37 | unsigned long get_softirq_status(); 38 | 39 | void softirq_init(); 40 | void do_softirq(); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /kernel/include/ssize.h: -------------------------------------------------------------------------------- 1 | #ifndef __SSIZE_H__ 2 | #define __SSIZE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | char * ssize(char * buf, double size); 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | 14 | #endif /* __SSIZE_H__ */ -------------------------------------------------------------------------------- /kernel/include/stddef.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDDEF_H__ 2 | #define __STDDEF_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #if defined(__cplusplus) 9 | #define NULL (0) 10 | #else 11 | #define NULL ((void *)0) 12 | #endif 13 | 14 | #if (__GNUC__ >= 4) 15 | #define offsetof(type, member) __builtin_offsetof(type, member) 16 | #else 17 | #define offsetof(type, field) ((size_t)(&((type *)0)->field)) 18 | #endif 19 | 20 | 21 | #define X(...) ("" #__VA_ARGS__ "") 22 | 23 | enum { 24 | FALSE = 0, 25 | TRUE = 1, 26 | }; 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif /* __STDDEF_H__ */ 33 | -------------------------------------------------------------------------------- /kernel/include/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDIO_H__ 2 | #define __STDIO_H__ 3 | 4 | #define stdin 0 5 | #define stdout 1 6 | #define stderr 2 7 | 8 | #include 9 | 10 | #ifndef EOF 11 | #define EOF (-1) 12 | #endif 13 | 14 | enum { 15 | SEEK_SET = 0, /* set file offset to offset */ 16 | SEEK_CUR = 1, /* set file offset to current plus offset */ 17 | SEEK_END = 2, /* set file offset to EOF plus offset */ 18 | }; 19 | 20 | 21 | #include 22 | #include 23 | 24 | extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); 25 | extern int snprintf(char * buf, size_t size, const char *fmt, ...); 26 | extern int vsprintf(char *buf, const char *fmt, va_list args); 27 | extern int sprintf(char * buf, const char *fmt, ...); 28 | extern int vsscanf(const char * buf, const char * fmt, va_list args); 29 | extern int vasprintf(char ** s, const char * fmt, va_list ap); 30 | extern int sscanf(const char * buf, const char * fmt, ...); 31 | 32 | int putchar(int c); 33 | int getchar(void); 34 | 35 | int printf(const char *fmt, ...); 36 | int scanf(const char * fmt, ...); 37 | 38 | #endif /* _STDIO_H */ 39 | -------------------------------------------------------------------------------- /kernel/include/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDLIB_H__ 2 | #define __STDLIB_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | #define RAND_MAX (0x7fffffff) 12 | 13 | typedef struct { int quot, rem; } div_t; 14 | typedef struct { long quot, rem; } ldiv_t; 15 | typedef struct { long long quot, rem; } lldiv_t; 16 | 17 | int rand(void); 18 | void srand(unsigned int seed); 19 | 20 | int abs(int n); 21 | long labs(long n); 22 | long long llabs(long long n); 23 | 24 | div_t div(int num, int den); 25 | ldiv_t ldiv(long num, long den); 26 | lldiv_t lldiv(long long num, long long den); 27 | 28 | int atoi(const char * nptr); 29 | long atol(const char * nptr); 30 | long long atoll(const char * nptr); 31 | double atof(const char * nptr); 32 | 33 | long strtol(const char * nptr, char ** endptr, int base); 34 | long long strtoll(const char * nptr, char ** endptr, int base); 35 | unsigned long strtoul(const char * nptr, char ** endptr, int base); 36 | unsigned long long strtoull(const char * nptr, char ** endptr, int base); 37 | double strtod(const char * nptr, char ** endptr); 38 | 39 | intmax_t strtoimax(const char * nptr, char ** endptr, int base); 40 | uintmax_t strtoumax(const char * nptr, char ** endptr, int base); 41 | intmax_t strntoimax(const char * nptr, char ** endptr, int base, size_t n); 42 | uintmax_t strntoumax(const char * nptr, char ** endptr, int base, size_t n); 43 | 44 | void * bsearch(const void * key, const void * base, size_t nmemb, size_t size, 45 | int (*compar)(const void *, const void *)); 46 | void qsort(void * aa, size_t n, size_t es, int (*cmp)(const void *, const void *)); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif /* __STDLIB_H__ */ 53 | -------------------------------------------------------------------------------- /kernel/include/sys/dirent.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __DIRENT_H__ 17 | #define __DIRENT_H__ 18 | 19 | struct dirent { 20 | long d_off; 21 | long d_type; 22 | long d_reclen; 23 | char d_name[]; 24 | }; 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /kernel/include/sys/err.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_ERR_H 2 | #define _SYS_ERR_H 3 | 4 | #define MAX_ERRNO 4095 5 | 6 | 7 | 8 | #define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO) 9 | 10 | static inline void * ERR_PTR(long error) 11 | { 12 | return (void *) error; 13 | } 14 | 15 | static inline long PTR_ERR(const void *ptr) 16 | { 17 | return (long) ptr; 18 | } 19 | 20 | static inline long IS_ERR(const void *ptr) 21 | { 22 | return IS_ERR_VALUE((unsigned long)ptr); 23 | } 24 | 25 | static inline long IS_ERR_OR_NULL(const void *ptr) 26 | { 27 | return !ptr || IS_ERR_VALUE((unsigned long)ptr); 28 | } 29 | 30 | /** 31 | * ERR_CAST - Explicitly cast an error-valued pointer to another pointer type 32 | * @ptr: The pointer to cast. 33 | * 34 | * Explicitly cast an error-valued pointer to another pointer type in such a 35 | * way as to make it clear that's what's going on. 36 | */ 37 | static inline void * ERR_CAST(const void *ptr) 38 | { 39 | /* cast away the const */ 40 | return (void *) ptr; 41 | } 42 | #endif -------------------------------------------------------------------------------- /kernel/include/sys/param.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_PARAM_H 2 | #define _SYS_PARAM_H 3 | 4 | #define OS_VERSION 0 5 | #define OS_RELEASE 3 6 | #define OS_PATCH 0 7 | 8 | #define HZ 100 9 | 10 | #define NR_OPEN 32 11 | 12 | #define NR_TASK 16 13 | 14 | #define NR_INODE 32 15 | 16 | #define NR_SUPER 4 17 | 18 | #define NR_BUFFER 128 19 | 20 | #define BUF_SIZE 1024 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /kernel/include/sys/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_SIGNAL_H 2 | #define _SYS_SIGNAL_H 3 | 4 | #define NR_SIG 32 5 | 6 | #define SIGHUP 1 7 | #define SIGINT 2 8 | #define SIGQUIT 3 9 | #define SIGILL 4 10 | #define SIGTRAP 5 11 | #define SIGABRT 6 12 | #define SIGFPU 7 13 | #define SIGKILL 8 14 | #define SIGUSR1 9 15 | #define SIGSEGV 10 16 | #define SIGUSR2 11 17 | #define SIGPIPE 12 18 | #define SIGALARM 13 19 | #define SIGTREM 14 20 | #define SIGCHLD 15 21 | #define SIGTKFLT 16 22 | #define SIGCONT 17 23 | #define SIGSTOP 18 24 | #define SIGTSTP 19 25 | #define SIGTTIN 20 26 | #define SIGTTOU 21 27 | #define SIGTERM 22 28 | 29 | typedef unsigned long sigset_t; 30 | typedef void (*sigact_t)(int signo, int ret); 31 | 32 | #define SIG_BLOCK 1 33 | #define SIG_UNBLOCK 2 34 | #define SIG_SETMASK 3 35 | 36 | #define SIG_ERR ((sigact_t)-1) 37 | #define SIG_DFL ((sigact_t)0) 38 | #define SIG_IGN ((sigact_t)1) 39 | 40 | #define signal(a,b) 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /kernel/include/sys/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIME_H 2 | #define _SYS_TIME_H 3 | 4 | #include 5 | #include 6 | 7 | #define CLOCKS_PER_SEC HZ 8 | #define CLK_TCK HZ 9 | 10 | #define isleap(y) (((y)%4==0&&(y)%100!=0)||(y)%400==0) 11 | 12 | struct timeval { 13 | time_t tv_sec; /* Seconds */ 14 | long tv_usec; /* Microseconds */ 15 | }; 16 | 17 | struct timespec { 18 | time_t tv_sec; /* Seconds */ 19 | long tv_nsec; /* Nanoseconds */ 20 | }; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /kernel/include/sys/times.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIMES_H 2 | #define _SYS_TIMES_H 3 | 4 | #include 5 | 6 | struct tms { 7 | clock_t tms_utime; 8 | clock_t tms_stime; 9 | clock_t tms_cutime; 10 | clock_t tms_cstime; 11 | }; 12 | 13 | clock_t times(struct tms *tmsptr); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /kernel/include/sys/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_UNISTD_H 2 | #define _SYS_UNISTD_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | /* standard I/O fileno */ 9 | #define STDIN_FILENO 0 /* file descriptor of stdin */ 10 | #define STDOUT_FILENO 1 /* file descriptor of stdout */ 11 | #define STDERR_FILENO 2 /* file descriptor of stderr */ 12 | 13 | #define PIPE_READ_ID 0 14 | #define PIPE_WRITE_ID 1 15 | 16 | extern char **environ; 17 | 18 | extern pid_t fork(); 19 | extern pid_t getpid(); 20 | extern pid_t getppid(); 21 | extern pid_t setgrp(); 22 | extern pid_t setsid(); 23 | extern uid_t getuid(); 24 | extern gid_t getgid(); 25 | extern uid_t setuid(uid_t uid); 26 | extern gid_t setgid(gid_t gid); 27 | extern ssize_t read(int fd, void * buf, size_t size); 28 | extern ssize_t write(int fd, void * buf, size_t size); 29 | extern int execve(char *fname, char **argv, char **envp); 30 | extern void _exit(int status); 31 | extern int sbrk(int inc); 32 | extern int dup(int fd); 33 | extern int dup2(int fd, int fd2); 34 | extern int chdir(char *dirname); 35 | extern int close(int fd); 36 | extern int lseek(int fd, long off, int where); 37 | extern int mkdir(char *name, mode_t mode); 38 | extern int rmdir(char *name); 39 | extern int link(const char *name, const char *newname); 40 | extern int sync(void); 41 | extern int unlink(const char *name); 42 | extern int mknod(char *name, mode_t mode, dev_t dev); 43 | extern int execvpe(char * file, char ** argv, char ** envp); 44 | extern int pipe(int fd[2]); 45 | extern int mount(char* special, char *target, char* type, int rw_flag); 46 | extern int umount(char* special); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /kernel/include/sys/wait.h: -------------------------------------------------------------------------------- 1 | /* 2 | * exit_code: high byte low byte 3 | * normal exit status 0 4 | * signal exit 0 signal 5 | * job control signal 0177 6 | */ 7 | 8 | #ifndef _SYS_WAIT_H 9 | #define _SYS_WAIT_H 10 | 11 | #include 12 | 13 | #define WNOHANG 0x01 /* Not hang if no status, return immediately. */ 14 | #define WUNTRACED 0x02 /* Report status of stopped child process. */ 15 | 16 | #define WIFEXITED(s) (!((s)&0xFF)) /* normal exit */ 17 | #define WIFSIGNALED(s) (((unsigned int)(s)-1)&xFFFF) /* signal exit */ 18 | #define WIFSTOPPED(s) (((s)&0xFF)==0x7F) /* job control */ 19 | #define WEXITSTATUS(s) (((s) >> 8) & 0377) /* exit status */ 20 | #define WTERMSIG(s) ((s)&0x7F) /* sig value */ 21 | #define WSTOPSIG(s) (((s)>>8)&0xFF) /* stop signal */ 22 | 23 | pid_t wait(pid_t pid, int *status, int options); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /kernel/include/syscalls.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | 17 | SYSCALL_COMMON(__NR_putstring, sys_putstring) 18 | 19 | SYSCALL_COMMON(__NR_open, sys_open) 20 | SYSCALL_COMMON(__NR_close, sys_close) 21 | SYSCALL_COMMON(__NR_read, sys_read) 22 | SYSCALL_COMMON(__NR_write, sys_write) 23 | SYSCALL_COMMON(__NR_lseek, sys_lseek) 24 | 25 | SYSCALL_COMMON(__NR_fork, sys_fork_wrapper) 26 | SYSCALL_COMMON(__NR_vfork, sys_vfork_wrapper) 27 | SYSCALL_COMMON(__NR_execve, sys_execve_wrapper) 28 | SYSCALL_COMMON(__NR_exit, sys_exit) 29 | SYSCALL_COMMON(__NR_wait4, sys_wait4) 30 | 31 | SYSCALL_COMMON(__NR_brk, sys_brk) 32 | SYSCALL_COMMON(__NR_reboot, sys_reboot) 33 | 34 | SYSCALL_COMMON(__NR_chdir, sys_chdir) 35 | 36 | SYSCALL_COMMON(__NR_getdents, sys_getdents) 37 | SYSCALL_COMMON(__NR_stat, sys_stat) 38 | SYSCALL_COMMON(__NR_fstat, sys_fstat) 39 | SYSCALL_COMMON(__NR_fstat, sys_mkdir) 40 | SYSCALL_COMMON(__NR_fstat, sys_rmdir) 41 | SYSCALL_COMMON(__NR_fstat, sys_rename) 42 | SYSCALL_COMMON(__NR_fstat, sys_mknod) 43 | -------------------------------------------------------------------------------- /kernel/include/time/delay.h: -------------------------------------------------------------------------------- 1 | #ifndef __DELAY_H__ 2 | #define __DELAY_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | void ndelay(u32_t ns); 11 | void udelay(u32_t us); 12 | void mdelay(u32_t ms); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif /* __DELAY_H__ */ 19 | -------------------------------------------------------------------------------- /kernel/include/time/timer.h: -------------------------------------------------------------------------------- 1 | #ifndef __TIMER_H__ 2 | #define __TIMER_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | struct timer_base_t; 13 | struct timer_t; 14 | 15 | enum timer_state_t { 16 | TIMER_STATE_INACTIVE = 0, 17 | TIMER_STATE_ENQUEUED = 1, 18 | TIMER_STATE_CALLBACK = 2, 19 | }; 20 | 21 | struct timer_base_t { 22 | struct rb_root head; 23 | struct timer_t * next; 24 | struct clockevent_t * ce; 25 | spinlock_t lock; 26 | }; 27 | 28 | struct timer_t { 29 | struct rb_node node; 30 | struct timer_base_t * base; 31 | enum timer_state_t state; 32 | ktime_t expires; 33 | void * data; 34 | int (*function)(struct timer_t *, void *); 35 | }; 36 | 37 | void timer_init(struct timer_t * timer, int (*function)(struct timer_t *, void *), void * data); 38 | void timer_start(struct timer_t * timer, ktime_t now, ktime_t interval); 39 | void timer_start_now(struct timer_t * timer, ktime_t interval); 40 | void timer_forward(struct timer_t * timer, ktime_t now, ktime_t interval); 41 | void timer_forward_now(struct timer_t * timer, ktime_t interval); 42 | void timer_cancel(struct timer_t * timer); 43 | 44 | void timer_bind_clockevent(struct clockevent_t * ce); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif /* __TIMER_H__ */ 51 | -------------------------------------------------------------------------------- /kernel/include/typecheck.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPECHECK_H_ 2 | #define TYPECHECK_H_ 3 | 4 | /* 5 | * Check at compile time that something is of a particular type. 6 | * Always evaluates to 1 so you may use it easily in comparisons. 7 | */ 8 | #define typecheck(type,x) \ 9 | ({ type __dummy; \ 10 | typeof(x) __dummy2; \ 11 | (void)(&__dummy == &__dummy2); \ 12 | 1; \ 13 | }) 14 | 15 | /* 16 | * Check at compile time that 'function' is a certain type, or is a pointer 17 | * to that type (needs to use typedef for the function type.) 18 | */ 19 | #define typecheck_fn(type,function) \ 20 | ({ typeof(type) __tmp = function; \ 21 | (void)__tmp; \ 22 | }) 23 | 24 | #endif /* TYPECHECK_H_INCLUDED */ 25 | -------------------------------------------------------------------------------- /kernel/include/uart/uart.h: -------------------------------------------------------------------------------- 1 | #ifndef __BUS_UART_H__ 2 | #define __BUS_UART_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct uart_t 11 | { 12 | /* The uart name */ 13 | char * name; 14 | 15 | /* Set uart param */ 16 | bool_t (*set)(struct uart_t * uart, int baud, int data, int parity, int stop); 17 | 18 | /* Get uart param */ 19 | bool_t (*get)(struct uart_t * uart, int * baud, int * data, int * parity, int * stop); 20 | 21 | /* Read uart */ 22 | ssize_t (*read)(struct uart_t * uart, u8_t * buf, size_t count); 23 | 24 | /* Write uart */ 25 | ssize_t (*write)(struct uart_t * uart, const u8_t * buf, size_t count); 26 | 27 | /* Private data */ 28 | void * priv; 29 | }; 30 | 31 | struct uart_t * search_uart(const char * name); 32 | bool_t register_uart(struct device_t ** device, struct uart_t * uart); 33 | bool_t unregister_uart(struct uart_t * uart); 34 | 35 | bool_t uart_set(struct uart_t * uart, int baud, int data, int parity, int stop); 36 | bool_t uart_get(struct uart_t * uart, int * baud, int * data, int * parity, int * stop); 37 | ssize_t uart_read(struct uart_t * uart, u8_t * buf, size_t count); 38 | ssize_t uart_write(struct uart_t * uart, const u8_t * buf, size_t count); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* __BUS_UART_H__ */ 45 | -------------------------------------------------------------------------------- /kernel/include/unistd.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __UNISTD_H__ 17 | 18 | #define __UNISTD_H__ 19 | 20 | #define __NR_putstring 1 21 | 22 | #define __NR_open 2 23 | #define __NR_close 3 24 | #define __NR_read 4 25 | #define __NR_write 5 26 | #define __NR_lseek 6 27 | 28 | #define __NR_fork 7 29 | #define __NR_vfork 8 30 | #define __NR_execve 9 31 | #define __NR_exit 10 32 | #define __NR_wait4 11 33 | 34 | #define __NR_brk 12 35 | #define __NR_reboot 13 36 | 37 | #define __NR_chdir 14 38 | #define __NR_getdents 15 39 | 40 | #define __NR_stat 16 41 | #define __NR_fstat 16 42 | #endif 43 | -------------------------------------------------------------------------------- /kernel/include/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __VERSION_H__ 2 | #define __VERSION_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | int xboot_version(void); 9 | const char * xboot_version_string(void); 10 | const char * xboot_banner_string(void); 11 | const char * xboot_character_logo_string(int i); 12 | 13 | #ifdef __cplusplus 14 | } 15 | #endif 16 | 17 | #endif /* __VERSION_H__ */ 18 | -------------------------------------------------------------------------------- /kernel/include/waitqueue.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __WAITQUEUE_H__ 17 | 18 | #define __WAITQUEUE_H__ 19 | 20 | #include "lib.h" 21 | 22 | typedef struct { 23 | struct list_head wait_list; 24 | struct task_t *tsk; 25 | } wait_queue_t; 26 | 27 | void wait_queue_init(wait_queue_t * wait_queue, struct task_t *tsk); 28 | 29 | void sleep_on(wait_queue_t * wait_queue_head); 30 | 31 | void wakeup(wait_queue_t * wait_queue_head); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /kernel/include/watchdog/watchdog.h: -------------------------------------------------------------------------------- 1 | #ifndef __WATCHDOG_H__ 2 | #define __WATCHDOG_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | struct watchdog_t 11 | { 12 | /* The watchdog name */ 13 | char * name; 14 | 15 | /* Set watchdog's timeout in seconds, zero means stop */ 16 | void (*set)(struct watchdog_t * wdg, int timeout); 17 | 18 | /* Get watchdog's timeout in seconds, remaining time */ 19 | int (*get)(struct watchdog_t * wdg); 20 | 21 | /* Private data */ 22 | void * priv; 23 | }; 24 | 25 | struct watchdog_t * search_watchdog(const char * name); 26 | struct watchdog_t * search_first_watchdog(void); 27 | bool_t register_watchdog(struct device_t ** device,struct watchdog_t * wdg); 28 | bool_t unregister_watchdog(struct watchdog_t * wdg); 29 | 30 | void watchdog_set_timeout(struct watchdog_t * wdg, int timeout); 31 | int watchdog_get_timeout(struct watchdog_t * wdg); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* __WATCHDOG_H__ */ 38 | -------------------------------------------------------------------------------- /kernel/init/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += main.o 2 | obj-y += version.o -------------------------------------------------------------------------------- /kernel/init/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int main() { 10 | 11 | do_init_memory(); 12 | 13 | do_init_slab(); 14 | 15 | do_init_class(); 16 | 17 | do_init_sched(); 18 | 19 | /* Do initial event */ 20 | do_init_event(); 21 | 22 | /* Do all initial calls */ 23 | do_initcalls(); 24 | 25 | task_init(); 26 | 27 | while (1); 28 | /* Do all exit calls */ 29 | do_exitcalls(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /kernel/kernel/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += core/ 2 | obj-y += time/ 3 | obj-y += command/ 4 | obj-y += shell/ 5 | obj-y += class/ 6 | obj-y += softirq.o 7 | obj-y += task.o 8 | obj-y += schedule.o 9 | obj-y += semaphore.o 10 | obj-y += waitqueue.o 11 | obj-y += preempt.o 12 | -------------------------------------------------------------------------------- /kernel/kernel/preempt.c: -------------------------------------------------------------------------------- 1 | #include 2 | long preempt_count(){ 3 | return current->preempt_count; 4 | } 5 | 6 | #define preempt_count() (current->preempt_count) 7 | 8 | void add_preempt_count(int val){ 9 | preempt_count() += (val); 10 | } 11 | void sub_preempt_count(int val){ 12 | preempt_count() -= (val); 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /kernel/kernel/semaphore.c: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | void semaphore_init(semaphore_T * semaphore, unsigned long count) { 25 | atomic_set(&semaphore->counter, count); 26 | wait_queue_init(&semaphore->wait, NULL); 27 | } 28 | 29 | void __up(semaphore_T * semaphore) { 30 | wait_queue_t * wait = list_entry(&semaphore->wait.wait_list, wait_queue_t, wait_list); 31 | 32 | list_del(&wait->wait_list); 33 | task_resume(wait->tsk); 34 | //TODO:调度策略 35 | current->flags |= NEED_SCHEDULE; 36 | } 37 | 38 | void semaphore_up(semaphore_T * semaphore) { 39 | if (list_empty(&semaphore->wait.wait_list)) 40 | atomic_inc(&semaphore->counter); 41 | else 42 | __up(semaphore); 43 | } 44 | 45 | void __down(semaphore_T * semaphore) { 46 | wait_queue_t wait; 47 | wait_queue_init(&wait, current); 48 | list_add_tail(&semaphore->wait.wait_list, &wait.wait_list); 49 | task_suspend(current); 50 | schedule(); 51 | } 52 | 53 | void semaphore_down(semaphore_T * semaphore) { 54 | if (atomic_read(&semaphore->counter) > 0) 55 | atomic_dec(&semaphore->counter); 56 | else 57 | __down(semaphore); 58 | } 59 | 60 | -------------------------------------------------------------------------------- /kernel/kernel/softirq.c: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #include "softirq.h" 17 | #include "lib.h" 18 | 19 | unsigned long softirq_status = 0; 20 | struct softirq softirq_vector[BITS_PER_LONG]; 21 | 22 | void set_softirq_status(unsigned long status) { 23 | softirq_status |= status; 24 | } 25 | 26 | unsigned long get_softirq_status() { 27 | return softirq_status; 28 | } 29 | 30 | void register_softirq(int nr, void (*action)(void * data), void * data) { 31 | softirq_vector[nr].action = action; 32 | softirq_vector[nr].data = data; 33 | } 34 | 35 | void unregister_softirq(int nr) { 36 | softirq_vector[nr].action = NULL; 37 | softirq_vector[nr].data = NULL; 38 | } 39 | 40 | void do_softirq() { 41 | int i; 42 | sti(); 43 | for (i = 0; i < BITS_PER_LONG && softirq_status; i++) { 44 | if (softirq_status & (1 << i)) { 45 | softirq_vector[i].action(softirq_vector[i].data); 46 | softirq_status &= ~(1 << i); 47 | } 48 | } 49 | cli(); 50 | } 51 | 52 | void softirq_init() { 53 | softirq_status = 0; 54 | memset(softirq_vector, 0, sizeof(struct softirq) * BITS_PER_LONG); 55 | } 56 | -------------------------------------------------------------------------------- /kernel/kernel/waitqueue.c: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #include 17 | #include "waitqueue.h" 18 | #include "task.h" 19 | #include "lib.h" 20 | #include "assert.h" 21 | 22 | void wait_queue_init(wait_queue_t * wait_queue, struct task_t *tsk) { 23 | init_list_head(&wait_queue->wait_list); 24 | wait_queue->tsk = tsk; 25 | } 26 | 27 | void sleep_on(wait_queue_t * wait_queue_head) { 28 | wait_queue_t wait; 29 | wait_queue_init(&wait, current); 30 | list_add_tail(&wait.wait_list, &wait_queue_head->wait_list); 31 | task_suspend(current); 32 | } 33 | 34 | 35 | void wakeup(wait_queue_t * wait_queue_head) { 36 | wait_queue_t * wait = NULL; 37 | 38 | if (list_empty(&wait_queue_head->wait_list)) 39 | return; 40 | 41 | wait = list_next_entry(wait_queue_head, wait_list); 42 | 43 | list_del(&wait->wait_list); 44 | wakeup_process(wait->tsk); 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /kernel/lib/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += libc/ 2 | obj-y += libm/ 3 | obj-y += libx/ 4 | #obj-y += lvgl/ 5 | obj-y += microui/ 6 | obj-y += vt100/ -------------------------------------------------------------------------------- /kernel/lib/libc/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += charset/ 2 | obj-y += ctype/ 3 | obj-y += exit/ 4 | obj-y += malloc/ 5 | obj-y += stdlib/ 6 | obj-y += crypto/ 7 | obj-y += errno/ 8 | obj-y += stdio/ 9 | obj-y += string/ -------------------------------------------------------------------------------- /kernel/lib/libc/ctype/ctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/lib/ctype.c 3 | * 4 | * Copyright (C) 1991, 1992 Linus Torvalds 5 | */ 6 | 7 | #include "ctype.h" 8 | 9 | unsigned char _ctype[] = { 10 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ 11 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ 12 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ 13 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ 14 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ 15 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ 16 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ 17 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ 18 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ 19 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ 20 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ 21 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ 22 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ 23 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ 24 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ 25 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ 26 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ 27 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ 28 | _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ 29 | _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ 30 | _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ 31 | _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ 32 | _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ 33 | _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ 34 | -------------------------------------------------------------------------------- /kernel/lib/libc/errno/errno.c: -------------------------------------------------------------------------------- 1 | 2 | int errno; 3 | -------------------------------------------------------------------------------- /kernel/lib/libc/exit/assert.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | void __Assert(char *msg){ 6 | printf("Assertion failed: %s\n",msg); 7 | local_irq_disable(); 8 | panic(); 9 | while(1); 10 | } 11 | -------------------------------------------------------------------------------- /kernel/lib/libc/malloc/malloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * lib/libc/malloc/malloc.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | static spinlock_t __heap_lock = SPIN_LOCK_INIT(); 14 | 15 | void * malloc(size_t size) 16 | { 17 | void * m; 18 | 19 | spin_lock(&__heap_lock); 20 | m = kmalloc(size, 0); 21 | spin_unlock(&__heap_lock); 22 | return m; 23 | } 24 | EXPORT_SYMBOL(malloc); 25 | 26 | void * memalign(size_t align, size_t size) 27 | { 28 | void * m; 29 | 30 | spin_lock(&__heap_lock); 31 | m = kmalloc(size, 0); 32 | if(((size_t)m) & (align - 1)) { 33 | kfree(m); 34 | return NULL; 35 | } 36 | spin_unlock(&__heap_lock); 37 | return m; 38 | } 39 | EXPORT_SYMBOL(memalign); 40 | 41 | /* TODO: 42 | void * realloc(void * ptr, size_t size) 43 | { 44 | void * m; 45 | 46 | spin_lock(&__heap_lock); 47 | m = tlsf_realloc(__heap_pool, ptr, size); 48 | spin_unlock(&__heap_lock); 49 | return m; 50 | } 51 | EXPORT_SYMBOL(realloc); 52 | */ 53 | 54 | void * calloc(size_t nmemb, size_t size) 55 | { 56 | void * m; 57 | 58 | if((m = malloc(nmemb * size))) 59 | memset(m, 0, nmemb * size); 60 | return m; 61 | } 62 | EXPORT_SYMBOL(calloc); 63 | 64 | void free(void * ptr) 65 | { 66 | if(!ptr) 67 | return; 68 | spin_lock(&__heap_lock); 69 | kfree(ptr); 70 | spin_unlock(&__heap_lock); 71 | } 72 | EXPORT_SYMBOL(free); 73 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/getchar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/getchar.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int getchar(void) 10 | { 11 | unsigned char res; 12 | while(console_stdin_read(&res, 1) <= 0); 13 | return res; 14 | } 15 | EXPORT_SYMBOL(getchar); 16 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/printf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/printf.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | static char buf[SZ_4K]; 12 | 13 | int printf(const char * fmt, ...) 14 | { 15 | va_list ap; 16 | int rv; 17 | 18 | va_start(ap, fmt); 19 | rv = vsnprintf(buf, SZ_4K, fmt, ap); 20 | va_end(ap); 21 | 22 | int len = strlen((const char *)buf); 23 | for (int i = 0; i < len; i++) 24 | putchar(buf[i]); 25 | return rv; 26 | } 27 | EXPORT_SYMBOL(printf); 28 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/putchar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/putchar.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int putchar(int c) 9 | { 10 | if (c == '\n') { 11 | int t = '\r'; 12 | console_stdout_write(&t, 1); 13 | } 14 | console_stdout_write(&c, 1); 15 | return c; 16 | } 17 | EXPORT_SYMBOL(putchar); 18 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/scanf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/scanf.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | int scanf(const char * fmt, ...) 12 | { 13 | va_list ap; 14 | char * buf; 15 | int rv; 16 | 17 | buf = malloc(SZ_4K); 18 | if(!buf) 19 | return 0; 20 | 21 | memset(buf, 0, SZ_4K); 22 | //fread(buf, 1, SZ_4K, stdin); 23 | 24 | va_start(ap, fmt); 25 | rv = vsscanf(buf, fmt, ap); 26 | va_end(ap); 27 | 28 | free(buf); 29 | return rv; 30 | } 31 | EXPORT_SYMBOL(scanf); 32 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/snprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/snprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int snprintf(char * buf, size_t n, const char * fmt, ...) 9 | { 10 | va_list ap; 11 | int rv; 12 | 13 | va_start(ap, fmt); 14 | rv = vsnprintf(buf, n, fmt, ap); 15 | va_end(ap); 16 | return rv; 17 | } 18 | EXPORT_SYMBOL(snprintf); 19 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/sprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/sprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int sprintf(char * buf, const char * fmt, ...) 9 | { 10 | va_list ap; 11 | int rv; 12 | 13 | va_start(ap, fmt); 14 | rv = vsnprintf(buf, ~(size_t)0, fmt, ap); 15 | va_end(ap); 16 | 17 | return rv; 18 | } 19 | EXPORT_SYMBOL(sprintf); 20 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/sscanf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/sscanf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int sscanf(const char * buf, const char * fmt, ...) 9 | { 10 | va_list ap; 11 | int rv; 12 | 13 | va_start(ap, fmt); 14 | rv = vsscanf(buf, fmt, ap); 15 | va_end(ap); 16 | 17 | return rv; 18 | } 19 | EXPORT_SYMBOL(sscanf); 20 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdio/vasprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdio/vasprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int vasprintf(char ** s, const char * fmt, va_list ap) 10 | { 11 | va_list ap2; 12 | int l; 13 | 14 | va_copy(ap2, ap); 15 | l = vsnprintf(0, 0, fmt, ap2); 16 | va_end(ap2); 17 | 18 | if((l < 0) || !(*s = malloc(l + 1))) 19 | return -1; 20 | return vsnprintf(*s, l + 1, fmt, ap); 21 | } 22 | EXPORT_SYMBOL(vasprintf); 23 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/abs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/abs.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int abs(int n) 9 | { 10 | return ((n < 0) ? -n : n); 11 | } 12 | EXPORT_SYMBOL(abs); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/atof.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/atof.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | double atof(const char * nptr) 9 | { 10 | return (double)strtod(nptr, 0); 11 | } 12 | EXPORT_SYMBOL(atof); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/atoi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/atoi.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int atoi(const char * nptr) 10 | { 11 | return (int)strtol(nptr, NULL, 10); 12 | } 13 | EXPORT_SYMBOL(atoi); 14 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/atol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/atol.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | long atol(const char * nptr) 10 | { 11 | return (long)strtol(nptr, NULL, 10); 12 | } 13 | EXPORT_SYMBOL(atol); 14 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/atoll.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/atoll.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | long long atoll(const char * nptr) 10 | { 11 | return (long long)strtoll(nptr, NULL, 10); 12 | } 13 | EXPORT_SYMBOL(atoll); 14 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/bsearch.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/bsearch.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Perform a binary search 12 | */ 13 | void * bsearch(const void * key, const void * base, size_t nmemb, size_t size, 14 | int (*compar)(const void *, const void *)) 15 | { 16 | size_t l, u, idx; 17 | const void *p; 18 | int comparison; 19 | 20 | l = 0; 21 | u = nmemb; 22 | while (l < u) 23 | { 24 | idx = (l + u) / 2; 25 | p = (void *) (((const char *) base) + (idx * size)); 26 | comparison = (*compar)(key, p); 27 | if (comparison < 0) 28 | u = idx; 29 | else if (comparison > 0) 30 | l = idx + 1; 31 | else 32 | return (void *) p; 33 | } 34 | 35 | return NULL; 36 | } 37 | EXPORT_SYMBOL(bsearch); 38 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/div.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/div.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | div_t div(int num, int den) 9 | { 10 | return (div_t){ num / den, num % den }; 11 | } 12 | EXPORT_SYMBOL(div); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/labs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/labs.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | long labs(long n) 9 | { 10 | return ((n < 0L) ? -n : n); 11 | } 12 | EXPORT_SYMBOL(labs); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/ldiv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/ldiv.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | ldiv_t ldiv(long num, long den) 9 | { 10 | return (ldiv_t){ num / den, num % den }; 11 | } 12 | EXPORT_SYMBOL(ldiv); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/llabs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/llabs.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | long long llabs(long long n) 9 | { 10 | return ((n < 0LL) ? -n : n); 11 | } 12 | EXPORT_SYMBOL(llabs); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/lldiv.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/lldiv.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | lldiv_t lldiv(long long num, long long den) 9 | { 10 | return (lldiv_t){ num / den, num % den }; 11 | } 12 | EXPORT_SYMBOL(lldiv); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/rand.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/rand.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Pseudo random seed - 48bits 11 | */ 12 | static unsigned short __seed[3] = {1, 1, 1}; 13 | 14 | static long jrand48(unsigned short * xsubi) 15 | { 16 | u64_t x; 17 | 18 | x = (u64_t)(u16_t)xsubi[0] + ((u64_t)(u16_t)xsubi[1] << 16) + ((u64_t)(u16_t)xsubi[2] << 32); 19 | x = (0x5deece66dULL * x) + 0xb; 20 | 21 | xsubi[0] = (unsigned short)(u16_t)x; 22 | xsubi[1] = (unsigned short)(u16_t)(x >> 16); 23 | xsubi[2] = (unsigned short)(u16_t)(x >> 32); 24 | 25 | return (long)(s32_t)(x >> 16); 26 | } 27 | 28 | static long lrand48(void) 29 | { 30 | return (u32_t)jrand48(__seed) >> 1; 31 | } 32 | 33 | static void srand48(long val) 34 | { 35 | ktime_t kt = ktime_get(); 36 | 37 | val ^= (long)(ktime_to_ns(kt) >> 32); 38 | val ^= (long)(ktime_to_ns(kt) >> 0); 39 | __seed[0] = 0x330e; 40 | __seed[1] = (unsigned short)val; 41 | __seed[2] = (unsigned short)((u32_t)val >> 16); 42 | } 43 | 44 | int rand(void) 45 | { 46 | return (int)lrand48(); 47 | } 48 | EXPORT_SYMBOL(rand); 49 | 50 | void srand(unsigned int seed) 51 | { 52 | srand48(seed); 53 | } 54 | EXPORT_SYMBOL(srand); 55 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/strntoimax.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/strntoimax.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | intmax_t strntoimax(const char * nptr, char ** endptr, int base, size_t n) 9 | { 10 | return (intmax_t)strntoumax(nptr, endptr, base, n); 11 | } 12 | EXPORT_SYMBOL(strntoimax); 13 | -------------------------------------------------------------------------------- /kernel/lib/libc/stdlib/strntoumax.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/stdlib/strntoumax.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | static inline int digitval(int ch) 10 | { 11 | unsigned d; 12 | 13 | d = (unsigned)(ch - '0'); 14 | if (d < 10) return (int)d; 15 | 16 | d = (unsigned)(ch - 'a'); 17 | if (d < 6) return (int)(d+10); 18 | 19 | d = (unsigned)(ch - 'A'); 20 | if (d < 6) return (int)(d+10); 21 | 22 | return -1; 23 | } 24 | 25 | uintmax_t strntoumax(const char * nptr, char ** endptr, int base, size_t n) 26 | { 27 | const unsigned char * p = (const unsigned char *) nptr; 28 | const unsigned char * end = p + n; 29 | int minus = 0; 30 | uintmax_t v = 0; 31 | int d; 32 | 33 | /* skip leading space */ 34 | while (p < end && isspace(*p)) 35 | p++; 36 | 37 | /* Single optional + or - */ 38 | if (p < end) 39 | { 40 | char c = p[0]; 41 | if (c == '-' || c == '+') 42 | { 43 | minus = (c == '-'); 44 | p++; 45 | } 46 | } 47 | 48 | if (base == 0) 49 | { 50 | if (p + 2 < end && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) 51 | { 52 | p += 2; 53 | base = 16; 54 | } 55 | else if (p + 1 < end && p[0] == '0') 56 | { 57 | p += 1; 58 | base = 8; 59 | } 60 | else 61 | { 62 | base = 10; 63 | } 64 | } 65 | else if (base == 16) 66 | { 67 | if (p + 2 < end && p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) 68 | { 69 | p += 2; 70 | } 71 | } 72 | 73 | while (p < end && (d = digitval(*p)) >= 0 && d < base) 74 | { 75 | v = v * base + d; 76 | p += 1; 77 | } 78 | 79 | if (endptr) 80 | *endptr = (char *) p; 81 | 82 | return minus ? -v : v; 83 | } 84 | EXPORT_SYMBOL(strntoumax); 85 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/memchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/memchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds the first occurrence of a byte in a buffer 12 | */ 13 | void * memchr(const void * s, int c, size_t n) 14 | { 15 | const unsigned char *p = s; 16 | 17 | while (n-- != 0) 18 | { 19 | if ((unsigned char)c == *p++) 20 | { 21 | return (void *)(p - 1); 22 | } 23 | } 24 | 25 | return NULL; 26 | } 27 | EXPORT_SYMBOL(memchr); 28 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/memcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/memcmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int memcmp(const void * s1, const void * s2, size_t n) 10 | { 11 | const unsigned char *su1, *su2; 12 | int res = 0; 13 | 14 | for (su1 = s1, su2 = s2; 0 < n; ++su1, ++su2, n--) 15 | if ((res = *su1 - *su2) != 0) 16 | break; 17 | return res; 18 | } 19 | 20 | /* 21 | * Compares two buffers 22 | */ 23 | EXPORT_SYMBOL(memcmp); 24 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/memcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/memcpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void * memcpy(void * dest, const void * src, size_t len) 10 | { 11 | char * tmp = dest; 12 | const char * s = src; 13 | 14 | while (len--) 15 | *tmp++ = *s++; 16 | return dest; 17 | } 18 | 19 | /* 20 | * Copies one buffer to another 21 | */ 22 | EXPORT_SYMBOL(memcpy); 23 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/memmove.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/memmove.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void * memmove(void * dest, const void * src, size_t n) 10 | { 11 | char * tmp; 12 | const char * s; 13 | 14 | if (dest <= src) 15 | { 16 | tmp = dest; 17 | s = src; 18 | while (n--) 19 | *tmp++ = *s++; 20 | } 21 | else 22 | { 23 | tmp = dest; 24 | tmp += n; 25 | s = src; 26 | s += n; 27 | while (n--) 28 | *--tmp = *--s; 29 | } 30 | return dest; 31 | } 32 | 33 | /* 34 | * Copies one buffer to another, possibly overlapping, buffer 35 | */ 36 | EXPORT_SYMBOL(memmove); 37 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/memscan.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/memscan.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Find a character in an area of memory 11 | */ 12 | void * memscan(void * addr, int c, size_t size) 13 | { 14 | unsigned char * p = addr; 15 | 16 | while (size) 17 | { 18 | if (*p == c) 19 | return (void *)p; 20 | p++; 21 | size--; 22 | } 23 | return (void *)p; 24 | } 25 | EXPORT_SYMBOL(memscan); 26 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/memset.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/memset.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void * memset(void * s, int c, size_t n) 10 | { 11 | char * xs = s; 12 | 13 | while (n--) 14 | *xs++ = c; 15 | 16 | return s; 17 | } 18 | 19 | /* 20 | * Fills a buffer with a repeated byte/wchar_t 21 | */ 22 | EXPORT_SYMBOL(memset); 23 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strcasecmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strcasecmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Compare two strings ignoring case 12 | */ 13 | int strcasecmp(const char * s1, const char * s2) 14 | { 15 | int c1, c2; 16 | 17 | do { 18 | c1 = tolower(*s1++); 19 | c2 = tolower(*s2++); 20 | } while (c1 == c2 && c1 != 0); 21 | 22 | return c1 - c2; 23 | } 24 | EXPORT_SYMBOL(strcasecmp); 25 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strcat.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | /* 9 | * Appends one string to another 10 | */ 11 | char * strcat(char * dest, const char * src) 12 | { 13 | char * tmp = dest; 14 | 15 | while (*dest) 16 | dest++; 17 | while ((*dest++ = *src++) != '\0'); 18 | 19 | return tmp; 20 | } 21 | EXPORT_SYMBOL(strcat); 22 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds the first occurrence of a byte in a string 12 | */ 13 | char * strchr(const char * s, int c) 14 | { 15 | for (; *s != (char)c; ++s) 16 | if (*s == '\0') 17 | return NULL; 18 | return (char *)s; 19 | } 20 | EXPORT_SYMBOL(strchr); 21 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strcmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | static int __strcmp(const char * s1, const char * s2) 10 | { 11 | int res; 12 | 13 | while (1) 14 | { 15 | if ((res = *s1 - *s2++) != 0 || !*s1++) 16 | break; 17 | } 18 | return res; 19 | } 20 | 21 | /* 22 | * Compares two strings 23 | */ 24 | extern __typeof(__strcmp) strcmp __attribute__((weak, alias("__strcmp"))); 25 | EXPORT_SYMBOL(strcmp); 26 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strcoll.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strcpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Compares two strings according to the current locale 11 | */ 12 | int strcoll(const char * s1, const char * s2) 13 | { 14 | return strcmp(s1, s2); 15 | } 16 | EXPORT_SYMBOL(strcoll); 17 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strcpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Copies one string to another 11 | */ 12 | char * strcpy(char * dest, const char * src) 13 | { 14 | char * tmp = dest; 15 | 16 | while ((*dest++ = *src++) != '\0'); 17 | return tmp; 18 | } 19 | EXPORT_SYMBOL(strcpy); 20 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strcspn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strcspn.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds in a string the last occurrence of a byte not in a set 12 | */ 13 | size_t strcspn(const char * s, const char * reject) 14 | { 15 | const char * p; 16 | const char * r; 17 | size_t count = 0; 18 | 19 | for (p = s; *p != '\0'; ++p) 20 | { 21 | for (r = reject; *r != '\0'; ++r) 22 | { 23 | if (*p == *r) 24 | return count; 25 | } 26 | ++count; 27 | } 28 | return count; 29 | } 30 | EXPORT_SYMBOL(strcspn); 31 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strdup.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strdup.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /* 12 | * Allocates and duplicates a string 13 | */ 14 | char * strdup(const char * s) 15 | { 16 | char * p; 17 | 18 | if(!s) 19 | return NULL; 20 | 21 | p = malloc(strlen(s) + 1); 22 | if(p) 23 | return(strcpy(p, s)); 24 | 25 | return NULL; 26 | } 27 | EXPORT_SYMBOL(strdup); 28 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strlcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strlcat.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * A variant of strcat that truncates the result to fit in the destination buffer 11 | */ 12 | size_t strlcat(char * dest, const char * src, size_t n) 13 | { 14 | size_t dsize = strlen(dest); 15 | size_t len = strlen(src); 16 | size_t res = dsize + len; 17 | 18 | dest += dsize; 19 | n -= dsize; 20 | 21 | if (len >= n) 22 | len = n-1; 23 | 24 | memcpy(dest, src, len); 25 | dest[len] = 0; 26 | 27 | return res; 28 | } 29 | EXPORT_SYMBOL(strlcat); 30 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strlcpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * A variant of strcpy that truncates the result to fit in the destination buffer 11 | */ 12 | size_t strlcpy(char * dest, const char * src, size_t n) 13 | { 14 | size_t len; 15 | size_t ret = strlen(src); 16 | 17 | if (n) 18 | { 19 | len = (ret >= n) ? n - 1 : ret; 20 | memcpy(dest, src, len); 21 | dest[len] = '\0'; 22 | } 23 | return ret; 24 | } 25 | EXPORT_SYMBOL(strlcpy); 26 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strlen.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Calculate the length of a string 11 | */ 12 | size_t strlen(const char * s) 13 | { 14 | const char * sc; 15 | 16 | for (sc = s; *sc != '\0'; ++sc); 17 | return sc - s; 18 | } 19 | EXPORT_SYMBOL(strlen); 20 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strncasecmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strncasecmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Compares the two strings s1 and s2, ignoring the case of the characters 12 | */ 13 | int strncasecmp(const char * s1, const char * s2, size_t n) 14 | { 15 | int c1, c2; 16 | 17 | do { 18 | c1 = tolower(*s1++); 19 | c2 = tolower(*s2++); 20 | } while ((--n > 0) && c1 == c2 && c1 != 0); 21 | 22 | return c1 - c2; 23 | } 24 | EXPORT_SYMBOL(strncasecmp); 25 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strncat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strncat.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Appends no more than n bytes from one string to another 11 | */ 12 | char * strncat(char * dest, const char * src, size_t n) 13 | { 14 | char * tmp = dest; 15 | 16 | if (n) 17 | { 18 | while (*dest) 19 | dest++; 20 | while ((*dest++ = *src++) != 0) 21 | { 22 | if (--n == 0) 23 | { 24 | *dest = '\0'; 25 | break; 26 | } 27 | } 28 | } 29 | 30 | return tmp; 31 | } 32 | EXPORT_SYMBOL(strncat); 33 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strnchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strnchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds the first occurrence of a byte in a string 12 | */ 13 | char * strnchr(const char * s, size_t n, int c) 14 | { 15 | for (; n-- && *s != '\0'; ++s) 16 | if (*s == (char)c) 17 | return (char *)s; 18 | return NULL; 19 | } 20 | EXPORT_SYMBOL(strnchr); 21 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strncmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strncmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int strncmp(const char * s1, const char * s2, size_t n) 10 | { 11 | int __res = 0; 12 | 13 | while (n) 14 | { 15 | if ((__res = *s1 - *s2++) != 0 || !*s1++) 16 | break; 17 | n--; 18 | } 19 | return __res; 20 | } 21 | 22 | /* 23 | * Compares a specific number of bytes in two strings 24 | */ 25 | 26 | EXPORT_SYMBOL(strncmp); 27 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strncpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strncpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Writes exactly n bytes, copying from source or adding nulls 11 | */ 12 | char * strncpy(char * dest, const char * src, size_t n) 13 | { 14 | char * tmp = dest; 15 | 16 | while (n) 17 | { 18 | if ((*tmp = *src) != 0) 19 | src++; 20 | tmp++; 21 | n--; 22 | } 23 | return dest; 24 | } 25 | EXPORT_SYMBOL(strncpy); 26 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strnicmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strnicmp.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Compare strings without case sensitivity 12 | */ 13 | int strnicmp(const char * s1, const char * s2, size_t n) 14 | { 15 | unsigned char c1 = 0, c2 = 0; 16 | 17 | if (n) 18 | { 19 | do { 20 | c1 = *s1; 21 | c2 = *s2; 22 | s1++; 23 | s2++; 24 | if (!c1) 25 | break; 26 | if (!c2) 27 | break; 28 | if (c1 == c2) 29 | continue; 30 | c1 = tolower(c1); 31 | c2 = tolower(c2); 32 | if (c1 != c2) 33 | break; 34 | } while (--n); 35 | } 36 | return (int)c1 - (int)c2; 37 | } 38 | EXPORT_SYMBOL(strnicmp); 39 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strnlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strnlen.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | /* 10 | * Determine the length of a fixed-size string 11 | */ 12 | size_t strnlen(const char * s, size_t n) 13 | { 14 | const char * sc; 15 | 16 | for (sc = s; n-- && *sc != '\0'; ++sc); 17 | return sc - s; 18 | } 19 | EXPORT_SYMBOL(strnlen); 20 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strnstr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strnstr.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Locate a substring in a strin 12 | */ 13 | char * strnstr(const char * s1, const char * s2, size_t n) 14 | { 15 | size_t l2; 16 | 17 | l2 = strlen(s2); 18 | if (!l2) 19 | return (char *)s1; 20 | 21 | while (n >= l2) 22 | { 23 | n--; 24 | if (!memcmp(s1, s2, l2)) 25 | return (char *)s1; 26 | s1++; 27 | } 28 | 29 | return NULL; 30 | } 31 | EXPORT_SYMBOL(strnstr); 32 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strpbrk.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strpbrk.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds in a string the first occurrence of a byte/wchar_t in a set 12 | */ 13 | char * strpbrk(const char * s1, const char * s2) 14 | { 15 | const char * sc1, * sc2; 16 | 17 | for (sc1 = s1; *sc1 != '\0'; ++sc1) 18 | { 19 | for (sc2 = s2; *sc2 != '\0'; ++sc2) 20 | { 21 | if (*sc1 == *sc2) 22 | return (char *)sc1; 23 | } 24 | } 25 | 26 | return NULL; 27 | } 28 | EXPORT_SYMBOL(strpbrk); 29 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strrchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strrchr.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds the last occurrence of a byte in a string 12 | */ 13 | char * strrchr(const char * s, int c) 14 | { 15 | const char * p = s + strlen(s); 16 | 17 | do { 18 | if (*p == (char)c) 19 | return (char *)p; 20 | } while (--p >= s); 21 | 22 | return NULL; 23 | } 24 | EXPORT_SYMBOL(strrchr); 25 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strsep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strsep.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Extract token from string 12 | */ 13 | char * strsep(char ** s, const char * ct) 14 | { 15 | char * sbegin = *s; 16 | char * end; 17 | 18 | if (sbegin == NULL) 19 | return NULL; 20 | 21 | end = strpbrk(sbegin, ct); 22 | if (end) 23 | *end++ = '\0'; 24 | *s = end; 25 | 26 | return sbegin; 27 | } 28 | EXPORT_SYMBOL(strsep); 29 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strspn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strspn.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds in a string the first occurrence of a byte not in a set 12 | */ 13 | size_t strspn(const char * s, const char * accept) 14 | { 15 | const char * p; 16 | const char * a; 17 | size_t count = 0; 18 | 19 | for (p = s; *p != '\0'; ++p) 20 | { 21 | for (a = accept; *a != '\0'; ++a) 22 | { 23 | if (*p == *a) 24 | break; 25 | } 26 | if (*a == '\0') 27 | return count; 28 | ++count; 29 | } 30 | return count; 31 | } 32 | EXPORT_SYMBOL(strspn); 33 | -------------------------------------------------------------------------------- /kernel/lib/libc/string/strstr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libc/string/strstr.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | /* 11 | * Finds the first occurrence of a substring in a string 12 | */ 13 | char * strstr(const char * s1, const char * s2) 14 | { 15 | size_t l1, l2; 16 | 17 | l2 = strlen(s2); 18 | if (!l2) 19 | return (char *)s1; 20 | 21 | l1 = strlen(s1); 22 | while (l1 >= l2) 23 | { 24 | l1--; 25 | if (!memcmp(s1, s2, l2)) 26 | return (char *)s1; 27 | s1++; 28 | } 29 | 30 | return NULL; 31 | } 32 | EXPORT_SYMBOL(strstr); 33 | -------------------------------------------------------------------------------- /kernel/lib/libm/fabs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double fabs(double x) 4 | { 5 | union {double f; uint64_t i;} u = {x}; 6 | u.i &= -1ULL/2; 7 | return u.f; 8 | } 9 | -------------------------------------------------------------------------------- /kernel/lib/libm/modf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | double modf(double x, double *iptr) 5 | { 6 | union {double f; uint64_t i;} u = {x}; 7 | uint64_t mask; 8 | int e = (int)(u.i>>52 & 0x7ff) - 0x3ff; 9 | 10 | /* no fractional part */ 11 | if (e >= 52) { 12 | *iptr = x; 13 | if (e == 0x400 && u.i<<12 != 0) /* nan */ 14 | return x; 15 | u.i &= 1ULL<<63; 16 | return u.f; 17 | } 18 | 19 | /* no integral part*/ 20 | if (e < 0) { 21 | u.i &= 1ULL<<63; 22 | *iptr = u.f; 23 | return x; 24 | } 25 | 26 | mask = -1ULL>>12>>e; 27 | if ((u.i & mask) == 0) { 28 | *iptr = x; 29 | u.i &= 1ULL<<63; 30 | return u.f; 31 | } 32 | u.i &= ~mask; 33 | *iptr = u.f; 34 | return x - u.f; 35 | } 36 | EXPORT_SYMBOL(modf); 37 | -------------------------------------------------------------------------------- /kernel/lib/libm/scalbn.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | double scalbn(double x, int n) 4 | { 5 | union {double f; uint64_t i;} u; 6 | double_t y = x; 7 | 8 | if (n > 1023) { 9 | y *= 0x1p1023; 10 | n -= 1023; 11 | if (n > 1023) { 12 | y *= 0x1p1023; 13 | n -= 1023; 14 | if (n > 1023) 15 | n = 1023; 16 | } 17 | } else if (n < -1022) { 18 | y *= 0x1p-1022; 19 | n += 1022; 20 | if (n < -1022) { 21 | y *= 0x1p-1022; 22 | n += 1022; 23 | if (n < -1022) 24 | n = -1022; 25 | } 26 | } 27 | u.i = (uint64_t)(0x3ff+n)<<52; 28 | x = y * u.f; 29 | return x; 30 | } 31 | -------------------------------------------------------------------------------- /kernel/lib/libx/print_hex.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libx/print_hex.c 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | void print_hex(char *data, int len){ 10 | for (int i = 0; i < (len + 15) / 16; i++) { 11 | /* 每行打印16个数据 */ 12 | for (int j = 0; j < 16; j++) { 13 | /* 先打印数值 */ 14 | unsigned char c = data[i * 16 + j]; 15 | if ((i * 16 + j) < len) 16 | printf("%02x ", c); 17 | else 18 | printf(" "); 19 | } 20 | 21 | printf(" | "); 22 | 23 | for (int j = 0; j < 16; j++) { 24 | /* 后打印字符 */ 25 | unsigned char c = data[i * 16 + j]; 26 | if ((i * 16 + j) < len){ 27 | if (!isprint(c)) 28 | putchar('.'); 29 | else 30 | putchar(c); 31 | } 32 | } 33 | printf("\n"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /kernel/lib/libx/ssize.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libx/ssize.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | char * ssize(char * buf, double size) 9 | { 10 | const char * unit[] = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; 11 | int count = 0; 12 | 13 | while((size > 1024) && (count < 8)) 14 | { 15 | size /= 1024; 16 | count++; 17 | } 18 | sprintf(buf, "%.3f%s", size, unit[count]); 19 | return buf; 20 | } 21 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += lv_core/ 2 | obj-y += lv_hal/ 3 | obj-y += lv_objx/ 4 | obj-y += lv_fonts/ 5 | obj-y += lv_misc/ 6 | obj-y += lv_themes/ 7 | obj-y += lv_draw/ 8 | 9 | obj-y += port/ 10 | 11 | SUBDIR_CPPFLAGS += $(patsubst %/, -I $(src)/%, $(obj-y)) 12 | SUBDIR_CPPFLAGS += -I$(src) 13 | SUBDIR_CPPFLAGS += -DLV_CONF_INCLUDE_SIMPLE 14 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_conf_checker.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Generates a chechker file for lv_conf.h from lv_conf_templ.h define all the not defined values 3 | ''' 4 | 5 | 6 | import re 7 | 8 | fin = open("lv_conf_templ.h", "r"); 9 | fout = open("lv_conf_checker.h", "w"); 10 | 11 | 12 | fout.write( 13 | '/**\n\ 14 | * GENERATED FILE, DO NOT EDIT IT!\n\ 15 | * @file lv_conf_checker.h\n\ 16 | * Make sure all the defines of lv_conf.h have a default value\n\ 17 | **/\n\ 18 | \n\ 19 | #ifndef LV_CONF_CHECKER_H\n\ 20 | #define LV_CONF_CHECKER_H\n\ 21 | ' 22 | ) 23 | 24 | inlines = fin.read().splitlines(); 25 | 26 | started = 0 27 | 28 | for i in inlines: 29 | if(not started): 30 | if('#define LV_CONF_H' in i): 31 | started = 1 32 | continue 33 | else: 34 | continue 35 | 36 | if('/*--END OF LV_CONF_H--*/' in i): break 37 | 38 | if(re.search('^ *# *define .*$', i)): 39 | new = re.sub('^ *# *define', '#define ', i) 40 | new = re.sub(' +', ' ', new) #Remove extra white spaces 41 | splitted = new.split(' ') 42 | fout.write('#ifndef ' + splitted[1] + '\n') 43 | fout.write(i + '\n') 44 | fout.write('#endif\n') 45 | else: 46 | fout.write(i + '\n') 47 | 48 | 49 | fout.write( 50 | '\n\ 51 | #endif /*LV_CONF_CHECKER_H*/\n\ 52 | ') 53 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_core/lv_core.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_group.c 2 | CSRCS += lv_indev.c 3 | CSRCS += lv_obj.c 4 | CSRCS += lv_refr.c 5 | CSRCS += lv_style.c 6 | CSRCS += lv_vdb.c 7 | CSRCS += lv_lang.c 8 | 9 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_core 10 | VPATH += :$(LVGL_DIR)/lvgl/lv_core 11 | 12 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_core" 13 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_draw/lv_draw.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_draw_vbasic.c 2 | CSRCS += lv_draw_rbasic.c 3 | CSRCS += lv_draw.c 4 | CSRCS += lv_draw_rect.c 5 | CSRCS += lv_draw_label.c 6 | CSRCS += lv_draw_line.c 7 | CSRCS += lv_draw_img.c 8 | CSRCS += lv_draw_arc.c 9 | CSRCS += lv_draw_triangle.c 10 | 11 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_draw 12 | VPATH += :$(LVGL_DIR)/lvgl/lv_draw 13 | 14 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_draw" 15 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_draw/lv_draw_arc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_arc.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_ARC_H 7 | #define LV_DRAW_ARC_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw an arc. (Can draw pie too with great thickness.) 32 | * @param center_x the x coordinate of the center of the arc 33 | * @param center_y the y coordinate of the center of the arc 34 | * @param radius the radius of the arc 35 | * @param mask the arc will be drawn only in this mask 36 | * @param start_angle the start angle of the arc (0 deg on the bottom, 90 deg on the right) 37 | * @param end_angle the end angle of the arc 38 | * @param style style of the arc (`body.thickness`, `body.main_color`, `body.opa` is used) 39 | * @param opa_scale scale down all opacities by the factor 40 | */ 41 | void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask, 42 | uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale); 43 | 44 | /********************** 45 | * MACROS 46 | **********************/ 47 | 48 | 49 | #ifdef __cplusplus 50 | } /* extern "C" */ 51 | #endif 52 | 53 | #endif /*LV_DRAW_ARC*/ 54 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_draw/lv_draw_label.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_label.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LABEL_H 7 | #define LV_DRAW_LABEL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Write a text 32 | * @param coords coordinates of the label 33 | * @param mask the label will be drawn only in this area 34 | * @param style pointer to a style 35 | * @param opa_scale scale down all opacities by the factor 36 | * @param txt 0 terminated text to write 37 | * @param flag settings for the text from 'txt_flag_t' enum 38 | * @param offset text offset in x and y direction (NULL if unused) 39 | * 40 | */ 41 | void lv_draw_label(const lv_area_t * coords,const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, 42 | const char * txt, lv_txt_flag_t flag, lv_point_t * offset); 43 | 44 | /********************** 45 | * MACROS 46 | **********************/ 47 | 48 | 49 | #ifdef __cplusplus 50 | } /* extern "C" */ 51 | #endif 52 | 53 | #endif /*LV_DRAW_LABEL_H*/ 54 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_draw/lv_draw_line.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_line.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_LINE_H 7 | #define LV_DRAW_LINE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | /** 30 | * Draw a line 31 | * @param point1 first point of the line 32 | * @param point2 second point of the line 33 | * @param mask the line will be drawn only on this area 34 | * @param style pointer to a line's style 35 | * @param opa_scale scale down all opacities by the factor 36 | */ 37 | void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * mask, 38 | const lv_style_t * style, lv_opa_t opa_scale); 39 | 40 | /********************** 41 | * MACROS 42 | **********************/ 43 | 44 | 45 | #ifdef __cplusplus 46 | } /* extern "C" */ 47 | #endif 48 | 49 | #endif /*LV_DRAW_LINE_H*/ 50 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_draw/lv_draw_rect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_rect.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_RECT_H 7 | #define LV_DRAW_RECT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | 30 | /** 31 | * Draw a rectangle 32 | * @param coords the coordinates of the rectangle 33 | * @param mask the rectangle will be drawn only in this mask 34 | * @param style pointer to a style 35 | * @param opa_scale scale down all opacities by the factor 36 | */ 37 | void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); 38 | 39 | /********************** 40 | * MACROS 41 | **********************/ 42 | 43 | 44 | #ifdef __cplusplus 45 | } /* extern "C" */ 46 | #endif 47 | 48 | #endif /*LV_DRAW_RECT_H*/ 49 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_draw/lv_draw_triangle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_draw_triangle.h 3 | * 4 | */ 5 | 6 | #ifndef LV_DRAW_TRIANGLE_H 7 | #define LV_DRAW_TRIANGLE_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_draw.h" 17 | 18 | /********************* 19 | * DEFINES 20 | *********************/ 21 | 22 | /********************** 23 | * TYPEDEFS 24 | **********************/ 25 | 26 | /********************** 27 | * GLOBAL PROTOTYPES 28 | **********************/ 29 | /*Experimental use for 3D modeling*/ 30 | #define USE_LV_TRIANGLE 1 31 | 32 | #if USE_LV_TRIANGLE != 0 33 | /** 34 | * 35 | * @param points pointer to an array with 3 points 36 | * @param mask the triangle will be drawn only in this mask 37 | * @param color color of the triangle 38 | */ 39 | void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, lv_color_t color); 40 | #endif 41 | 42 | /********************** 43 | * MACROS 44 | **********************/ 45 | 46 | 47 | #ifdef __cplusplus 48 | } /* extern "C" */ 49 | #endif 50 | 51 | #endif /*LV_DRAW_TRIANGLE_H*/ 52 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_fonts/lv_fonts.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_font_builtin.c 2 | CSRCS += lv_font_dejavu_10.c 3 | CSRCS += lv_font_dejavu_20.c 4 | CSRCS += lv_font_dejavu_30.c 5 | CSRCS += lv_font_dejavu_40.c 6 | CSRCS += lv_font_dejavu_10_cyrillic.c 7 | CSRCS += lv_font_dejavu_20_cyrillic.c 8 | CSRCS += lv_font_dejavu_30_cyrillic.c 9 | CSRCS += lv_font_dejavu_40_cyrillic.c 10 | CSRCS += lv_font_dejavu_10_latin_sup.c 11 | CSRCS += lv_font_dejavu_20_latin_sup.c 12 | CSRCS += lv_font_dejavu_30_latin_sup.c 13 | CSRCS += lv_font_dejavu_40_latin_sup.c 14 | CSRCS += lv_font_symbol_10.c 15 | CSRCS += lv_font_symbol_20.c 16 | CSRCS += lv_font_symbol_30.c 17 | CSRCS += lv_font_symbol_40.c 18 | CSRCS += lv_font_monospace_8.c 19 | 20 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_fonts 21 | VPATH += :$(LVGL_DIR)/lvgl/lv_fonts 22 | 23 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_fonts" 24 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_hal/lv_hal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hal.h 3 | * 4 | */ 5 | 6 | #ifndef HAL_H 7 | #define HAL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #include "lv_hal_disp.h" 17 | #include "lv_hal_indev.h" 18 | #include "lv_hal_tick.h" 19 | 20 | /********************* 21 | * DEFINES 22 | *********************/ 23 | 24 | /********************** 25 | * TYPEDEFS 26 | **********************/ 27 | 28 | /********************** 29 | * GLOBAL PROTOTYPES 30 | **********************/ 31 | 32 | /********************** 33 | * MACROS 34 | **********************/ 35 | 36 | #ifdef __cplusplus 37 | } /* extern "C" */ 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_hal/lv_hal.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_hal_disp.c 2 | CSRCS += lv_hal_indev.c 3 | CSRCS += lv_hal_tick.c 4 | 5 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_hal 6 | VPATH += :$(LVGL_DIR)/lvgl/lv_hal 7 | 8 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_hal" 9 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_hal/lv_hal_tick.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_hal_tick.h 3 | * Provide access to the system tick with 1 millisecond resolution 4 | */ 5 | 6 | #ifndef LV_HAL_TICK_H 7 | #define LV_HAL_TICK_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | #include 22 | #include 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | #ifndef LV_ATTRIBUTE_TICK_INC 28 | #define LV_ATTRIBUTE_TICK_INC 29 | #endif 30 | 31 | /********************** 32 | * TYPEDEFS 33 | **********************/ 34 | 35 | /********************** 36 | * GLOBAL PROTOTYPES 37 | **********************/ 38 | 39 | /** 40 | * You have to call this function periodically 41 | * @param tick_period the call period of this function in milliseconds 42 | */ 43 | LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period); 44 | 45 | /** 46 | * Get the elapsed milliseconds since start up 47 | * @return the elapsed milliseconds 48 | */ 49 | uint32_t lv_tick_get(void); 50 | 51 | /** 52 | * Get the elapsed milliseconds since a previous time stamp 53 | * @param prev_tick a previous time stamp (return value of systick_get() ) 54 | * @return the elapsed milliseconds since 'prev_tick' 55 | */ 56 | uint32_t lv_tick_elaps(uint32_t prev_tick); 57 | 58 | /********************** 59 | * MACROS 60 | **********************/ 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif /*LV_HAL_TICK_H*/ 67 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_misc/lv_gc.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_gc.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | #include "lv_gc.h" 11 | 12 | /********************* 13 | * DEFINES 14 | *********************/ 15 | 16 | /********************** 17 | * TYPEDEFS 18 | **********************/ 19 | 20 | /********************** 21 | * STATIC PROTOTYPES 22 | **********************/ 23 | 24 | /********************** 25 | * STATIC VARIABLES 26 | **********************/ 27 | #if (!defined(LV_ENABLE_GC)) || LV_ENABLE_GC == 0 28 | LV_ROOTS 29 | #endif /* LV_ENABLE_GC */ 30 | /********************** 31 | * MACROS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL FUNCTIONS 36 | **********************/ 37 | 38 | /********************** 39 | * STATIC FUNCTIONS 40 | **********************/ 41 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_misc/lv_misc.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_font.c 2 | CSRCS += lv_circ.c 3 | CSRCS += lv_area.c 4 | CSRCS += lv_task.c 5 | CSRCS += lv_fs.c 6 | CSRCS += lv_anim.c 7 | CSRCS += lv_mem.c 8 | CSRCS += lv_ll.c 9 | CSRCS += lv_color.c 10 | CSRCS += lv_txt.c 11 | CSRCS += lv_ufs.c 12 | CSRCS += lv_math.c 13 | CSRCS += lv_log.c 14 | CSRCS += lv_gc.c 15 | 16 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_misc 17 | VPATH += :$(LVGL_DIR)/lvgl/lv_misc 18 | 19 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_misc" 20 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_misc/lv_templ.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.c 3 | * 4 | */ 5 | 6 | /********************* 7 | * INCLUDES 8 | *********************/ 9 | 10 | /********************* 11 | * DEFINES 12 | *********************/ 13 | 14 | /********************** 15 | * TYPEDEFS 16 | **********************/ 17 | 18 | /********************** 19 | * STATIC PROTOTYPES 20 | **********************/ 21 | 22 | /********************** 23 | * STATIC VARIABLES 24 | **********************/ 25 | 26 | /********************** 27 | * MACROS 28 | **********************/ 29 | 30 | /********************** 31 | * GLOBAL FUNCTIONS 32 | **********************/ 33 | 34 | /********************** 35 | * STATIC FUNCTIONS 36 | **********************/ 37 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_misc/lv_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_templ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TEMPL_H 7 | #define LV_TEMPL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | 17 | /********************* 18 | * DEFINES 19 | *********************/ 20 | 21 | /********************** 22 | * TYPEDEFS 23 | **********************/ 24 | 25 | /********************** 26 | * GLOBAL PROTOTYPES 27 | **********************/ 28 | 29 | /********************** 30 | * MACROS 31 | **********************/ 32 | 33 | 34 | #ifdef __cplusplus 35 | } /* extern "C" */ 36 | #endif 37 | 38 | #endif /*LV_TEMPL_H*/ 39 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_objx/lv_objx.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_arc.c 2 | CSRCS += lv_bar.c 3 | CSRCS += lv_cb.c 4 | CSRCS += lv_ddlist.c 5 | CSRCS += lv_kb.c 6 | CSRCS += lv_line.c 7 | CSRCS += lv_mbox.c 8 | CSRCS += lv_preload.c 9 | CSRCS += lv_roller.c 10 | CSRCS += lv_table.c 11 | CSRCS += lv_tabview.c 12 | CSRCS += lv_tileview.c 13 | CSRCS += lv_btn.c 14 | CSRCS += lv_calendar.c 15 | CSRCS += lv_chart.c 16 | CSRCS += lv_canvas.c 17 | CSRCS += lv_gauge.c 18 | CSRCS += lv_label.c 19 | CSRCS += lv_list.c 20 | CSRCS += lv_slider.c 21 | CSRCS += lv_ta.c 22 | CSRCS += lv_spinbox.c 23 | CSRCS += lv_btnm.c 24 | CSRCS += lv_cont.c 25 | CSRCS += lv_img.c 26 | CSRCS += lv_imgbtn.c 27 | CSRCS += lv_led.c 28 | CSRCS += lv_lmeter.c 29 | CSRCS += lv_page.c 30 | CSRCS += lv_sw.c 31 | CSRCS += lv_win.c 32 | 33 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_objx 34 | VPATH += :$(LVGL_DIR)/lvgl/lv_objx 35 | 36 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_objx" 37 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_porting/lv_port_disp_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_port_disp_templ.h 3 | * 4 | */ 5 | 6 | /*Copy this file as "lv_port_disp.h" and set this value to "1" to enable content*/ 7 | #if 0 8 | 9 | #ifndef LV_PORT_DISP_TEMPL_H 10 | #define LV_PORT_DISP_TEMPL_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /********************* 17 | * INCLUDES 18 | *********************/ 19 | #include "lvgl/lvgl.h" 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * GLOBAL PROTOTYPES 31 | **********************/ 32 | 33 | /********************** 34 | * MACROS 35 | **********************/ 36 | 37 | 38 | #ifdef __cplusplus 39 | } /* extern "C" */ 40 | #endif 41 | 42 | #endif /*LV_PORT_DISP_TEMPL_H*/ 43 | 44 | #endif /*Disable/Enable content*/ 45 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_porting/lv_port_fs_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_port_fs_templ.h 3 | * 4 | */ 5 | 6 | /*Copy this file as "lv_port_fs.h" and set this value to "1" to enable content*/ 7 | #if 0 8 | 9 | #ifndef LV_PORT_FS_TEMPL_H 10 | #define LV_PORT_FS_TEMPL_H 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /********************* 17 | * INCLUDES 18 | *********************/ 19 | #include "lvgl/lvgl.h" 20 | 21 | /********************* 22 | * DEFINES 23 | *********************/ 24 | 25 | /********************** 26 | * TYPEDEFS 27 | **********************/ 28 | 29 | /********************** 30 | * GLOBAL PROTOTYPES 31 | **********************/ 32 | 33 | /********************** 34 | * MACROS 35 | **********************/ 36 | 37 | 38 | #ifdef __cplusplus 39 | } /* extern "C" */ 40 | #endif 41 | 42 | #endif /*LV_PORT_FS_TEMPL_H*/ 43 | 44 | #endif /*Disable/Enable content*/ 45 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_porting/lv_port_indev_templ.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @file lv_port_indev_templ.h 4 | * 5 | */ 6 | 7 | /*Copy this file as "lv_port_indev.h" and set this value to "1" to enable content*/ 8 | #if 0 9 | 10 | #ifndef LV_PORT_INDEV_TEMPL_H 11 | #define LV_PORT_INDEV_TEMPL_H 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | /********************* 18 | * INCLUDES 19 | *********************/ 20 | #include "lvgl/lvgl.h" 21 | 22 | /********************* 23 | * DEFINES 24 | *********************/ 25 | 26 | /********************** 27 | * TYPEDEFS 28 | **********************/ 29 | 30 | /********************** 31 | * GLOBAL PROTOTYPES 32 | **********************/ 33 | 34 | /********************** 35 | * MACROS 36 | **********************/ 37 | 38 | 39 | #ifdef __cplusplus 40 | } /* extern "C" */ 41 | #endif 42 | 43 | #endif /*LV_PORT_INDEV_TEMPL_H*/ 44 | 45 | #endif /*Disable/Enable content*/ 46 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_alien.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_alien.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_ALIEN_H 7 | #define LV_THEME_ALIEN_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_ALIEN 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the alien theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_alien_init(uint16_t hue, lv_font_t *font); 43 | /** 44 | * Get a pointer to the theme 45 | * @return pointer to the theme 46 | */ 47 | lv_theme_t * lv_theme_get_alien(void); 48 | 49 | /********************** 50 | * MACROS 51 | **********************/ 52 | 53 | #endif 54 | 55 | #ifdef __cplusplus 56 | } /* extern "C" */ 57 | #endif 58 | 59 | #endif /*LV_THEME_ALIEN_H*/ 60 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_default.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_default.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_DEFAULT_H 7 | #define LV_THEME_DEFAULT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_DEFAULT 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the default theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_default_init(uint16_t hue, lv_font_t *font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_default(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_TEMPL_H*/ 61 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_material.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_material.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_MATERIAL_H 7 | #define LV_THEME_MATERIAL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_MATERIAL 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the material theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_material_init(uint16_t hue, lv_font_t *font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_material(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_MATERIAL_H*/ 61 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_mono.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_mono.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_MONO_H 7 | #define LV_THEME_MONO_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_MONO 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the mono theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_mono_init(uint16_t hue, lv_font_t *font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_mono(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_MONO_H*/ 61 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_nemo.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_nemo.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_NEMO_H 7 | #define LV_THEME_NEMO_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_NEMO 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the material theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_nemo_init(uint16_t hue, lv_font_t *font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_nemo(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_NEMO_H*/ 61 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_night.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_night.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_NIGHT_H 7 | #define LV_THEME_NIGHT_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_NIGHT 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the night theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_night_init(uint16_t hue, lv_font_t *font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_night(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_NIGHT_H*/ 61 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_templ.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_templ.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_TEMPL_H 7 | #define LV_THEME_TEMPL_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_TEMPL 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the templ theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_templ_init(uint16_t hue, lv_font_t *font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_templ(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_TEMPL_H*/ 61 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_theme_zen.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_theme_zen.h 3 | * 4 | */ 5 | 6 | #ifndef LV_THEME_ZEN_H 7 | #define LV_THEME_ZEN_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lv_conf.h" 18 | #else 19 | #include "../../lv_conf.h" 20 | #endif 21 | 22 | #if USE_LV_THEME_ZEN 23 | 24 | /********************* 25 | * DEFINES 26 | *********************/ 27 | 28 | /********************** 29 | * TYPEDEFS 30 | **********************/ 31 | 32 | /********************** 33 | * GLOBAL PROTOTYPES 34 | **********************/ 35 | 36 | /** 37 | * Initialize the zen theme 38 | * @param hue [0..360] hue value from HSV color space to define the theme's base color 39 | * @param font pointer to a font (NULL to use the default) 40 | * @return pointer to the initialized theme 41 | */ 42 | lv_theme_t * lv_theme_zen_init(uint16_t hue, lv_font_t *font); 43 | 44 | /** 45 | * Get a pointer to the theme 46 | * @return pointer to the theme 47 | */ 48 | lv_theme_t * lv_theme_get_zen(void); 49 | 50 | /********************** 51 | * MACROS 52 | **********************/ 53 | 54 | #endif 55 | 56 | #ifdef __cplusplus 57 | } /* extern "C" */ 58 | #endif 59 | 60 | #endif /*LV_THEME_ZEN_H*/ 61 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_themes/lv_themes.mk: -------------------------------------------------------------------------------- 1 | CSRCS += lv_theme_alien.c 2 | CSRCS += lv_theme.c 3 | CSRCS += lv_theme_default.c 4 | CSRCS += lv_theme_night.c 5 | CSRCS += lv_theme_templ.c 6 | CSRCS += lv_theme_zen.c 7 | CSRCS += lv_theme_material.c 8 | CSRCS += lv_theme_nemo.c 9 | CSRCS += lv_theme_mono.c 10 | 11 | DEPPATH += --dep-path $(LVGL_DIR)/lvgl/lv_themes 12 | VPATH += :$(LVGL_DIR)/lvgl/lv_themes 13 | 14 | CFLAGS += "-I$(LVGL_DIR)/lvgl/lv_themes" 15 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/lv_version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_version.h 3 | * 4 | */ 5 | 6 | #ifndef LV_VERSION_H 7 | #define LV_VERSION_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | /*Current version of LittlevGL*/ 17 | #define LVGL_VERSION_MAJOR 5 18 | #define LVGL_VERSION_MINOR 3 19 | #define LVGL_VERSION_PATCH 0 20 | #define LVGL_VERSION_INFO "" 21 | 22 | 23 | /********************* 24 | * DEFINES 25 | *********************/ 26 | 27 | /********************** 28 | * TYPEDEFS 29 | **********************/ 30 | 31 | /********************** 32 | * GLOBAL PROTOTYPES 33 | **********************/ 34 | 35 | /********************** 36 | * MACROS 37 | **********************/ 38 | /* Gives 1 if the x.y.z version is supported in the current version 39 | * Usage: 40 | * 41 | * - Require v6 42 | * #if LV_VERSION_CHECK(6,0,0) 43 | * new_func_in_v6(); 44 | * #endif 45 | * 46 | * 47 | * - Require at least v5.3 48 | * #if LV_VERSION_CHECK(5,3,0) 49 | * new_feature_from_v5_3(); 50 | * #endif 51 | * 52 | * 53 | * - Require v5.3.2 bugfixes 54 | * #if LV_VERSION_CHECK(5,3,2) 55 | * bugfix_in_v5_3_2(); 56 | * #endif 57 | * 58 | * */ 59 | #define LV_VERSION_CHECK(x,y,z) (x == LVGL_VERSION_MAJOR && (y < LVGL_VERSION_MINOR || (y == LVGL_VERSION_MINOR && z <= LVGL_VERSION_PATCH))) 60 | 61 | 62 | #ifdef __cplusplus 63 | } /* extern "C" */ 64 | #endif 65 | 66 | #endif /*LV_VERSION_H*/ 67 | -------------------------------------------------------------------------------- /kernel/lib/lvgl/port/lv_tutorial_porting.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lv_ex_porting.h 3 | * 4 | */ 5 | 6 | #ifndef LV_TUTORIAL_PORTING_H 7 | #define LV_TUTORIAL_PORTING_H 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | /********************* 14 | * INCLUDES 15 | *********************/ 16 | #ifdef LV_CONF_INCLUDE_SIMPLE 17 | #include "lvgl.h" 18 | //#include "lv_ex_conf.h" 19 | #else 20 | #include "../../../lvgl/lvgl.h" 21 | #include "../../../lv_ex_conf.h" 22 | #endif 23 | 24 | #if 1 25 | 26 | /********************* 27 | * DEFINES 28 | *********************/ 29 | 30 | /********************** 31 | * TYPEDEFS 32 | **********************/ 33 | 34 | /********************** 35 | * GLOBAL PROTOTYPES 36 | **********************/ 37 | void lv_tutorial_porting(void); 38 | 39 | /********************** 40 | * MACROS 41 | **********************/ 42 | 43 | #endif /*USE_LV_TUTORIALS*/ 44 | 45 | #ifdef __cplusplus 46 | } /* extern "C" */ 47 | #endif 48 | 49 | #endif /*LV_TUTORIAL_PORTING_H*/ 50 | -------------------------------------------------------------------------------- /kernel/lib/microui/renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDERER_H 2 | #define RENDERER_H 3 | 4 | #include "microui.h" 5 | 6 | void r_init(void); 7 | void r_draw_rect(mu_Rect rect, mu_Color color); 8 | void r_draw_text(const char *text, mu_Vec2 pos, mu_Color color); 9 | void r_draw_icon(int id, mu_Rect rect, mu_Color color); 10 | int r_get_text_width(const char *text, int len); 11 | int r_get_text_height(void); 12 | void r_set_clip_rect(mu_Rect rect); 13 | void r_draw_custom(mu_Rect rect, mu_Color *color); 14 | void r_clear(mu_Color color); 15 | void r_present(void); 16 | 17 | #endif 18 | 19 | -------------------------------------------------------------------------------- /kernel/lib/vt100/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += console-virt.o 2 | obj-y += vt100.o 3 | obj-y += test.o -------------------------------------------------------------------------------- /kernel/mm/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += memory.o -------------------------------------------------------------------------------- /kernel/scripts/Makefile.conf: -------------------------------------------------------------------------------- 1 | PHONY += conf 2 | 3 | conf : $(obj)/include/config/auto.conf $(obj)/include/config/autoconf.h 4 | 5 | $(obj)/include/config/autoconf.h : FORCE 6 | $(if $(wildcard $(obj)/include/config),:,@echo [MKDIR] $(obj)/include/config && $(MKDIR) $(obj)/include/config) 7 | $(if $(wildcard $(obj)/include/config/autoconf.h),:,@touch $(obj)/include/config/autoconf.h) 8 | @$(CC) -E -P -dM $(DEFINES) $(X_INCDIRS) $(srctree)/$(src)/include/kconfigs.h \ 9 | | sed -n -e "/\#define\s\+CONFIG_[[:alnum:]_]*/p" \ 10 | | sed -n -e "s/\s*$$//p" \ 11 | > $(obj)/include/config/autoconf.temp 12 | @$(CD) $(obj)/include/config && grep -vxf autoconf.temp autoconf.h \ 13 | | sed -n -e "s/\#define\s\+CONFIG_\([[:alnum:]_]*\).*/\L\1\E.h/p" \ 14 | | xargs touch autoconf.h 15 | @$(CD) $(obj)/include/config && grep -vxf autoconf.h autoconf.temp \ 16 | | sed -n -e "s/\#define\s\+CONFIG_\([[:alnum:]_]*\).*/\L\1\E.h/p" \ 17 | | xargs touch autoconf.h 18 | @$(RM) $(obj)/include/config/autoconf.h 19 | @echo [AUTOCONF] 20 | @$(MV) $(obj)/include/config/autoconf.temp $(obj)/include/config/autoconf.h 21 | 22 | $(obj)/include/config/auto.conf : $(obj)/include/config/autoconf.h 23 | @$(RM) $(obj)/include/config/auto.conf 24 | @$(CD) $(obj)/include/config && cat autoconf.h \ 25 | | sed -n -e "s/\#define\s\+\(CONFIG_[[:alnum:]_]*\)[[:space:]]/\1=/p" \ 26 | >> auto.conf 27 | @$(CD) $(obj)/include/config && cat autoconf.h \ 28 | | sed -n -e "s/\#define\s\+\(CONFIG_[[:alnum:]_]*\)$$/\1=y/p" \ 29 | >> auto.conf 30 | -------------------------------------------------------------------------------- /tools/qemu-system/linux/realview-dbg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | 4 | # The qemu's root directory. 5 | export QEMU_DIR=$(cd `dirname $0` ; pwd) 6 | 7 | cd ${QEMU_DIR} 8 | if [ ! -e ${QEMU_DIR}/sdcard/sdcard.img ]; then 9 | mkdir -p ${QEMU_DIR}/sdcard; 10 | unzip ${QEMU_DIR}/sdcard.zip -d ${QEMU_DIR}/sdcard > /dev/null; 11 | fi 12 | 13 | # Run qemu 14 | setsid bash -c "gnome-terminal -x qemu-system-arm -M realview-pb-a8 -m 256M \ 15 | -name \"ARM RealView Platform Baseboard for Cortex-A8\" \ 16 | -S -gdb tcp::10001,ipv4 \ 17 | -show-cursor -rtc base=localtime -serial stdio \ 18 | -sd sdcard/sdcard.img \ 19 | -net nic,macaddr=88:88:88:11:22:33,model=lan9118 -net user \ 20 | -kernel ../../../kernel/system &" 21 | -------------------------------------------------------------------------------- /tools/qemu-system/linux/realview-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | 4 | # The qemu's root directory. 5 | export QEMU_DIR=$(cd `dirname $0` ; pwd) 6 | 7 | cd ${QEMU_DIR} 8 | if [ ! -e ${QEMU_DIR}/sdcard/sdcard.img ]; then 9 | mkdir -p ${QEMU_DIR}/sdcard; 10 | unzip ${QEMU_DIR}/sdcard.zip -d ${QEMU_DIR}/sdcard > /dev/null; 11 | fi 12 | 13 | # Run qemu 14 | setsid bash -c "gnome-terminal -x qemu-system-arm -M realview-pb-a8 -m 256M \ 15 | -name \"ARM RealView Platform Baseboard for Cortex-A8\" \ 16 | -show-cursor -rtc base=localtime -serial stdio \ 17 | -sd sdcard/sdcard.img \ 18 | -net nic,macaddr=88:88:88:11:22:33,model=lan9118 -net user \ 19 | -kernel ../../../kernel/system &" 20 | -------------------------------------------------------------------------------- /tools/qemu-system/windows/realview-dbg.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @set SDL_STDIO_REDIRECT=0 3 | @set QEMU_DIR=%~dp0 4 | 5 | cd %QEMU_DIR% 6 | 7 | chcp 65001 8 | 9 | if exist "sdcard\sdcard.img" goto RunQemu 10 | mkdir "sdcard\" 11 | unzip.exe sdcard.zip -d "sdcard" 12 | 13 | :RunQemu 14 | start qemu-system-arm.exe -M realview-pb-a8 -m 256M ^ 15 | -name "ARM RealView Platform Baseboard for Cortex-A8" ^ 16 | -S -gdb tcp::10001,ipv4 ^ 17 | -show-cursor -rtc base=localtime -serial stdio ^ 18 | -sd "sdcard\sdcard.img" ^ 19 | -net nic,macaddr=88:88:88:11:22:33,model=lan9118 -net user ^ 20 | -kernel ..\..\..\kernel\system 21 | -------------------------------------------------------------------------------- /tools/qemu-system/windows/realview-run.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @set SDL_STDIO_REDIRECT=0 3 | @set QEMU_DIR=%~dp0 4 | 5 | cd %QEMU_DIR% 6 | 7 | chcp 65001 8 | 9 | if exist "sdcard\sdcard.img" goto RunQemu 10 | mkdir "sdcard\" 11 | unzip.exe sdcard.zip -d "sdcard" 12 | 13 | :RunQemu 14 | qemu-system-arm.exe -M realview-pb-a8 -m 256M ^ 15 | -name "ARM RealView Platform Baseboard for Cortex-A8" ^ 16 | -show-cursor -rtc base=localtime -serial stdio ^ 17 | -sd "sdcard\sdcard.img" ^ 18 | -net nic,macaddr=88:88:88:11:22:33,model=lan9118 -net user ^ 19 | -kernel ..\..\..\kernel\system 20 | -------------------------------------------------------------------------------- /user/arch/arm32/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += lib/ 2 | obj-y += $(MACH)/ 3 | obj-y += $(patsubst $(srctree)/$(src)/%.c, %.o, $(wildcard $(srctree)/$(src)/*.c)) \ 4 | $(patsubst $(srctree)/$(src)/%.S, %.o, $(wildcard $(srctree)/$(src)/*.S)) -------------------------------------------------------------------------------- /user/arch/arm32/include/asm/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_ARM_COMPILER_H 2 | #define __ASM_ARM_COMPILER_H 3 | 4 | /* 5 | * This is used to ensure the compiler did actually allocate the register we 6 | * asked it for some inline assembly sequences. Apparently we can't trust 7 | * the compiler from one version to another so a bit of paranoia won't hurt. 8 | * This string is meant to be concatenated with the inline asm string and 9 | * will cause compilation to stop on mismatch. 10 | * (for details, see gcc PR 15089) 11 | */ 12 | #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t" 13 | 14 | 15 | #endif /* __ASM_ARM_COMPILER_H */ 16 | -------------------------------------------------------------------------------- /user/arch/arm32/include/asm/unwind.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_UNWIND_H 2 | #define __ASM_UNWIND_H 3 | 4 | #ifdef CONFIG_ARM_UNWIND 5 | #define UNWIND(code...) code 6 | #else 7 | #define UNWIND(code...) 8 | #endif 9 | 10 | #endif /* __ASM_UNWIND_H */ 11 | -------------------------------------------------------------------------------- /user/arch/arm32/include/linkage.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINKAGE_H_ 2 | #define _LINKAGE_H_ 3 | 4 | #define L1_CACHE_BYTES 32 5 | #define asmlinkage __attribute__((regparm(0))) 6 | #define ____cacheline_aligned __attribute__((__aligned__(L1_CACHE_BYTES))) 7 | 8 | #define __ALIGN .align 0 9 | #define __ALIGN_STR ".align 0" 10 | 11 | #define ALIGN __ALIGN 12 | #define ALIGN_STR __ALIGN_STR 13 | 14 | #ifndef ENTRY 15 | #define ENTRY(name) \ 16 | .globl name; \ 17 | ALIGN; \ 18 | name: 19 | #endif 20 | 21 | #ifndef WEAK 22 | #define WEAK(name) \ 23 | .weak name; \ 24 | name: 25 | #endif 26 | 27 | #ifndef END 28 | #define END(name) \ 29 | .size name, .-name 30 | #endif 31 | 32 | /* If symbol 'name' is treated as a subroutine (gets called, and returns) 33 | * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of 34 | * static analysis tools such as stack depth analyzer. 35 | */ 36 | 37 | #define ENDPROC(name) \ 38 | .type name, %function; \ 39 | END(name) 40 | 41 | #define ARM(x...) x 42 | #define THUMB(x...) 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /user/arch/arm32/mach-x4418/Makefile: -------------------------------------------------------------------------------- 1 | extra-y += head.o 2 | 3 | obj-y += lib/ 4 | obj-y += $(filter-out $(extra-y), \ 5 | $(patsubst $(srctree)/$(src)/%.c, %.o, $(wildcard $(srctree)/$(src)/*.c)) \ 6 | $(patsubst $(srctree)/$(src)/%.S, %.o, $(wildcard $(srctree)/$(src)/*.S))) 7 | -------------------------------------------------------------------------------- /user/arch/arm32/mach-x4418/Makefile.mach: -------------------------------------------------------------------------------- 1 | DEFINES += -D__ARM32_ARCH__=7 -D__CORTEX_A9__ -D__ARM32_NEON__ 2 | 3 | WFLAGS := -Wall -Wno-unused 4 | 5 | ASFLAGS := $(WFLAGS) 6 | CFLAGS := $(WFLAGS) 7 | LDFLAGS := -T $(srctree)/arch/$(ARCH)/$(MACH)/user.lds -nostdlib 8 | 9 | MCFLAGS := -std=gnu99 -O3 \ 10 | -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 \ 11 | -ffreestanding -mfloat-abi=hard -fsigned-char \ 12 | -fno-omit-frame-pointer \ 13 | -marm -mno-thumb-interwork -mno-unaligned-access 14 | 15 | MASFLAGS := -D__ASSEMBLY__ 16 | MLDFLAGS := 17 | 18 | LIBDIRS := 19 | LIBS := 20 | -------------------------------------------------------------------------------- /user/arch/arm32/mach-x4418/head.S: -------------------------------------------------------------------------------- 1 | #include 2 | .text 3 | ENTRY(_start) 4 | //TODO:清除BSS 5 | b main 6 | 7 | -------------------------------------------------------------------------------- /user/arch/arm32/mach-x4418/include/configs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZhUyU1997/MINE_OS/2cf7026a21762e3dfb2fe2338ceedb51e9b7b9ca/user/arch/arm32/mach-x4418/include/configs.h -------------------------------------------------------------------------------- /user/arch/arm32/mach-x4418/user.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") 2 | OUTPUT_ARCH(arm) 3 | ENTRY(_start) 4 | 5 | SECTIONS { 6 | . = 0x800000; 7 | .text : 8 | { 9 | PROVIDE(_text = .); 10 | arch/arm32/mach-x4418/head.o; 11 | *(.text*); 12 | PROVIDE(_etext = .); 13 | } 14 | 15 | . = ALIGN(4); 16 | .data : 17 | { 18 | PROVIDE(_data = .); 19 | *(.data); 20 | PROVIDE(_edata = .); 21 | } 22 | 23 | . = ALIGN(4); 24 | .rodata : 25 | { 26 | PROVIDE(_rodata = .); 27 | *(.rodata); 28 | PROVIDE(_erodata = .); 29 | } 30 | . = ALIGN(4); 31 | .bss : 32 | { 33 | PROVIDE(_bss = .); 34 | *(.bss); 35 | *(COMMON); 36 | PROVIDE(_ebss = .); 37 | } 38 | 39 | _end = .; 40 | } 41 | -------------------------------------------------------------------------------- /user/include/kconfigs.h: -------------------------------------------------------------------------------- 1 | #include -------------------------------------------------------------------------------- /user/include/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef __STDIO_H__ 2 | #define __STDIO_H__ 3 | 4 | #include 5 | 6 | enum { 7 | SEEK_SET = 0, /* set file offset to offset */ 8 | SEEK_CUR = 1, /* set file offset to current plus offset */ 9 | SEEK_END = 2, /* set file offset to EOF plus offset */ 10 | }; 11 | 12 | int printf(const char *fmt, ...); 13 | int sprintf(char * buf,const char * fmt,...); 14 | int vsprintf(char * buf,const char *fmt, va_list args); 15 | 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /user/include/stdlib.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __STDLIB_H__ 17 | 18 | #define __STDLIB_H__ 19 | 20 | void * malloc(unsigned long size); 21 | void free(void * address); 22 | 23 | void exit(int status); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /user/include/syscall.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __SYSCALL_H__ 17 | 18 | #define __SYSCALL_H__ 19 | 20 | #define __NR_putstring 1 21 | #define __NR_open 2 22 | #define __NR_close 3 23 | #define __NR_read 4 24 | #define __NR_write 5 25 | #define __NR_lseek 6 26 | #define __NR_fork 7 27 | #define __NR_vfork 8 28 | #define __NR_execve 9 29 | #define __NR_exit 10 30 | #define __NR_wait4 11 31 | #define __NR_brk 12 32 | #define __NR_reboot 13 33 | #define __NR_chdir 14 34 | #define __NR_getdents 15 35 | 36 | extern int syscall(int num, ...); 37 | //TOOD 38 | unsigned long putstring(char *string); 39 | unsigned long open(char *filename, int flags); 40 | unsigned long close(int fd); 41 | unsigned long read(int fd, void * buf, long count); 42 | unsigned long write(int fd, void * buf, long count); 43 | unsigned long lseek(int filds, long offset, int whence); 44 | unsigned long fork(); 45 | unsigned long vfork(); 46 | unsigned long execve(char *name, char *argv[], char *envp[]); 47 | unsigned long exit(int exit_code); 48 | unsigned long wait4(unsigned long pid, int *status, int options, void *rusage); 49 | unsigned long brk(unsigned long brk); 50 | unsigned long reboot(unsigned long cmd, void * arg); 51 | unsigned long chdir(char *filename); 52 | unsigned long getdents(int fd, void * dirent, long count); 53 | 54 | #define PP_FILL(...) PP_FILL_I(__VA_ARGS__, 0, 0, 0, 0, 0, 0, 0) 55 | #define PP_FILL_I(e1, e2, e3, e4, e5, e6, e7, ...) e1, e2, e3, e4, e5, e6, e7 56 | #define syscall(...) syscall(PP_FILL(__VA_ARGS__)) 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /user/lib/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += printf.o 2 | obj-y += string.o -------------------------------------------------------------------------------- /user/lib/printf.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #ifndef __PRINTF_H__ 17 | 18 | #define __PRINTF_H__ 19 | 20 | #include 21 | 22 | #define ZEROPAD 1 /* pad with zero */ 23 | #define SIGN 2 /* unsigned/signed long */ 24 | #define PLUS 4 /* show plus */ 25 | #define SPACE 8 /* space if plus */ 26 | #define LEFT 16 /* left justified */ 27 | #define SPECIAL 32 /* 0x */ 28 | #define SMALL 64 /* use 'abcdef' instead of 'ABCDEF' */ 29 | 30 | #define is_digit(c) ((c) >= '0' && (c) <= '9') 31 | 32 | /* 33 | 34 | */ 35 | 36 | #include 37 | 38 | /** 39 | * strlen - Find the length of a string 40 | * @s: The string to be sized 41 | */ 42 | static inline int strlen(const char * s) 43 | { 44 | const char *sc; 45 | 46 | for (sc = s; *sc != '\0'; ++sc) 47 | /* nothing */; 48 | return sc - s; 49 | } 50 | 51 | 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /user/lib/string.c: -------------------------------------------------------------------------------- 1 | /** 2 | * memset - Fill a region of memory with the given value 3 | * @s: Pointer to the start of the area. 4 | * @c: The byte to fill the area with 5 | * @count: The size of the area. 6 | * 7 | * Do not use memset() to access IO space, use memset_io() instead. 8 | */ 9 | typedef unsigned int size_t; 10 | void * memset(void * s,int c,size_t count) 11 | { 12 | char *xs = (char *) s; 13 | 14 | while (count--) 15 | *xs++ = c; 16 | 17 | return s; 18 | } -------------------------------------------------------------------------------- /user/scripts/Makefile.conf: -------------------------------------------------------------------------------- 1 | PHONY += conf 2 | 3 | conf : $(obj)/include/config/auto.conf $(obj)/include/config/autoconf.h 4 | 5 | $(obj)/include/config/autoconf.h : $(srctree)/$(src)/include/kconfigs.h \ 6 | $(wildcard $(srctree)/arch/$(ARCH)/$(MACH)/include/configs.h) 7 | $(if $(wildcard $(obj)/include/config),:,@echo [MKDIR] $(obj)/include/config && $(MKDIR) $(obj)/include/config) 8 | $(if $(wildcard $(obj)/include/config/autoconf.h),:,@touch $(obj)/include/config/autoconf.h) 9 | @$(CC) -E -P -dM $(DEFINES) $(X_INCDIRS) $(srctree)/$(src)/include/kconfigs.h \ 10 | | sed -n -e "/\#define\s\+CONFIG_[[:alnum:]_]*/p" \ 11 | | sed -n -e "s/\s*$$//p" \ 12 | > $(obj)/include/config/autoconf.temp 13 | @$(CD) $(obj)/include/config && grep -vxf autoconf.temp autoconf.h \ 14 | | sed -n -e "s/\#define\s\+CONFIG_\([[:alnum:]_]*\).*/\L\1\E.h/p" \ 15 | | xargs touch autoconf.h 16 | @$(CD) $(obj)/include/config && grep -vxf autoconf.h autoconf.temp \ 17 | | sed -n -e "s/\#define\s\+CONFIG_\([[:alnum:]_]*\).*/\L\1\E.h/p" \ 18 | | xargs touch autoconf.h 19 | @$(RM) $(obj)/include/config/autoconf.h 20 | @echo [AUTOCONF] 21 | @$(MV) $(obj)/include/config/autoconf.temp $(obj)/include/config/autoconf.h 22 | 23 | $(obj)/include/config/auto.conf : $(obj)/include/config/autoconf.h 24 | @$(RM) $(obj)/include/config/auto.conf 25 | @$(CD) $(obj)/include/config && cat autoconf.h \ 26 | | sed -n -e "s/\#define\s\+\(CONFIG_[[:alnum:]_]*\)[[:space:]]/\1=/p" \ 27 | >> auto.conf 28 | @$(CD) $(obj)/include/config && cat autoconf.h \ 29 | | sed -n -e "s/\#define\s\+\(CONFIG_[[:alnum:]_]*\)$$/\1=y/p" \ 30 | >> auto.conf -------------------------------------------------------------------------------- /user/src/Makefile: -------------------------------------------------------------------------------- 1 | obj-y += test.o 2 | obj-y += lib.o 3 | obj-y += errno.o 4 | obj-y += syscall.o -------------------------------------------------------------------------------- /user/src/errno.c: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #include "errno.h" 17 | 18 | int errno = 0; 19 | -------------------------------------------------------------------------------- /user/src/lib.c: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #include "syscall.h" 17 | 18 | #define PP_HELP(x) #x 19 | #define SYSFUNC_DEF(name) \ 20 | _SYSFUNC_DEF_(name,__NR_##name) 21 | #define _SYSFUNC_DEF_(name,nr) __SYSFUNC_DEF__(name,nr) 22 | #define __SYSFUNC_DEF__(name,nr) \ 23 | __asm__ ( \ 24 | ".global " #name " \n\t" \ 25 | ".type " #name ", #function \n\t" \ 26 | #name ": \n\t" \ 27 | "ldmia sp, { r4-r5 } \n\t" \ 28 | "mov r7, #" PP_HELP(nr) "\n\t" \ 29 | "stmdb sp!, { lr } \n\t" \ 30 | "swi #0 \n\t" \ 31 | "ldmia sp!, { pc } \n\t" \ 32 | ); 33 | 34 | 35 | SYSFUNC_DEF(putstring) 36 | SYSFUNC_DEF(open) 37 | SYSFUNC_DEF(close) 38 | SYSFUNC_DEF(read) 39 | SYSFUNC_DEF(write) 40 | SYSFUNC_DEF(lseek) 41 | SYSFUNC_DEF(fork) 42 | SYSFUNC_DEF(vfork) 43 | SYSFUNC_DEF(execve) 44 | SYSFUNC_DEF(exit) 45 | SYSFUNC_DEF(wait4) 46 | SYSFUNC_DEF(brk) 47 | SYSFUNC_DEF(reboot) 48 | SYSFUNC_DEF(chdir) 49 | SYSFUNC_DEF(getdents) 50 | 51 | 52 | -------------------------------------------------------------------------------- /user/src/syscall.S: -------------------------------------------------------------------------------- 1 | #include 2 | ENTRY(syscall) 3 | mov r7, r0 4 | mov r0, r1 5 | mov r1, r2 6 | mov r2, r3 7 | ldmia sp, { r3-r5 } 8 | //TODO:由于现在都在svc模式,lr会丢失,因此要保存lr 9 | stmdb sp!, { lr } 10 | swi #0 11 | ldmia sp!, { pc } 12 | -------------------------------------------------------------------------------- /user/src/test.c: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | * 版权声明 3 | * 4 | * 本操作系统名为:MINE 5 | * 该操作系统未经授权不得以盈利或非盈利为目的进行开发, 6 | * 只允许个人学习以及公开交流使用 7 | * 8 | * 代码最终所有权及解释权归田宇所有; 9 | * 10 | * 本模块作者: 田宇 11 | * EMail: 345538255@qq.com 12 | * 13 | * 14 | ***************************************************/ 15 | 16 | #include "stdio.h" 17 | #include "stdlib.h" 18 | 19 | int main(int argc,char *argv[]) 20 | { 21 | int i = 0; 22 | putstring("Hello World!\n"); 23 | printf("Hello World!\n"); 24 | printf("argc:%d,argv:%#p\n",argc,argv); 25 | for(i = 0;i