├── .gitignore
├── .gitmodules
├── .project
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── defconfig
├── lpc1769.config
├── lpc17xx.config
├── qemu-orig.config
├── qemu.config
├── qemunet.config
├── stm32f407-discovery.config
├── stm32f429i-discovery.config
├── stm32f746-discovery.config
├── stm32f746-nucleo.config
└── stm32f769-discovery.config
├── gdbinit.bflt
├── gdbinit.mini
├── include
└── frosted_api.h
├── kconfig
├── .gitignore
├── Kconfig
├── Makefile
├── Makefile.frosted
├── POTFILES.in
├── STM32F4x1Discovery.cfg
├── check.sh
├── conf.c
├── confdata.c
├── expr.c
├── expr.h
├── frosted.conf
├── gconf.c
├── gconf.glade
├── images.c
├── kxgettext.c
├── list.h
├── lkc.h
├── lkc_proto.h
├── lpc17xx.cfg
├── lxdialog
│ ├── .gitignore
│ ├── BIG.FAT.WARNING
│ ├── check-lxdialog.sh
│ ├── checklist.c
│ ├── dialog.h
│ ├── inputbox.c
│ ├── menubox.c
│ ├── textbox.c
│ ├── util.c
│ └── yesno.c
├── mconf.c
├── menu.c
├── merge_config.sh
├── nconf.c
├── nconf.gui.c
├── nconf.h
├── qconf.cc
├── qconf.h
├── qemu2.cfg
├── streamline_config.pl
├── symbol.c
├── util.c
├── zconf.gperf
├── zconf.hash.c_shipped
├── zconf.l
├── zconf.lex.c_shipped
├── zconf.tab.c_shipped
└── zconf.y
├── kernel
├── Kconfig
├── adc.h
├── bflt.c
├── bflt.h
├── cdc_acm.h
├── cdc_ecm.h
├── cirbuf.c
├── cirbuf.h
├── crypto
│ ├── aes.c
│ ├── aes.h
│ ├── misc.c
│ ├── misc.h
│ ├── sha256.c
│ └── sha256.h
├── device.h
├── drivers
│ ├── device.c
│ ├── devusb_cdc_ecm.c
│ ├── dma.h
│ ├── dsp.h
│ ├── eth.h
│ ├── exti.c
│ ├── exti.h
│ ├── fbcon.c
│ ├── fbcon.h
│ ├── fonts.h
│ ├── fortuna.c
│ ├── framebuffer.h
│ ├── frand.c
│ ├── ft5336.c
│ ├── gpio.c
│ ├── gpio.h
│ ├── i2c.h
│ ├── ili9341.c
│ ├── l3gd20.c
│ ├── l3gd20.h
│ ├── lis3dsh.c
│ ├── lis3dsh.h
│ ├── lm3s_eth.c
│ ├── lsm303dlhc.c
│ ├── lsm303dlhc.h
│ ├── ltdc.h
│ ├── mccog21.c
│ ├── null.c
│ ├── pty.c
│ ├── pty.h
│ ├── rng.h
│ ├── sdio.h
│ ├── sdram.h
│ ├── socket_in.c
│ ├── socket_in.h
│ ├── socket_un.c
│ ├── spi.h
│ ├── stm32_dma.c
│ ├── stm32_eth.c
│ ├── stm32_i2c.c
│ ├── stm32_lowpower.c
│ ├── stm32_rng.c
│ ├── stm32_sdio.c
│ ├── stm32_sdio.h
│ ├── stm32_spi.c
│ ├── stm32_usb.c
│ ├── stm32f4_adc.c
│ ├── stm32f4_dsp.c
│ ├── stm32f4_sdram.c
│ ├── stm32f7_ltdc.c
│ ├── stm32f7_sdram.c
│ ├── stmpe811.c
│ ├── stmpe811.h
│ ├── tty_console.c
│ ├── tty_console.h
│ ├── uart.c
│ ├── uart.h
│ ├── uart_dev.h
│ ├── usb.h
│ ├── usb
│ │ ├── usb_kbd.c
│ │ └── usbh_drivers.h
│ └── xadow_LED_5x7.c
├── fonts
│ ├── cga_8x8.c
│ ├── palette_256_xterm.c
│ └── piccolo_7x6.c
├── fortuna.h
├── fpb.c
├── fpb.h
├── framebuffer.c
├── frand.h
├── frosted.c
├── frosted.h
├── fs
│ ├── fatfs.c
│ ├── fatfs.h
│ ├── memfs.c
│ ├── sysfs.c
│ ├── xipfs.c
│ └── xipfs.h
├── getaddrinfo.c
├── hardfault_debug.c
├── heap.h
├── interrupts.h
├── kprintf.c
├── kprintf.h
├── lm3s
│ ├── Kconfig
│ ├── lm3s.c
│ ├── lm3s.ld.in
│ └── lm3s6965evb.c
├── locks.c
├── locks.h
├── lowpower.h
├── lpc17xx.h
├── lpc17xx
│ ├── Kconfig
│ ├── lpc1768mbed.c
│ ├── lpc1769xpresso.c
│ └── lpc17xx.ld.in
├── malloc.c
├── malloc.h
├── module.c
├── mpu.c
├── mpu.h
├── mutex.S
├── net
│ ├── Kconfig
│ ├── if.h
│ ├── pico_lock.c
│ └── route.h
├── nrf51
│ ├── Kconfig
│ ├── blenanov1_5.c
│ └── nrf51.ld.in
├── nrf52
│ ├── Kconfig
│ ├── blenanov2_0.c
│ └── nrf52.ld.in
├── null.h
├── pico_port.h
├── pipe.c
├── scheduler.c
├── scheduler.h
├── semaphore.S
├── stm32f4
│ ├── Kconfig
│ ├── stm32f4.ld.in
│ ├── stm32f407discovery.c
│ ├── stm32f407diymore.c
│ ├── stm32f411nucleo.c
│ ├── stm32f429discovery.c
│ ├── stm32f446nucleo.c
│ ├── stm32f4x1discovery.c
│ └── stm32f4xxpyboard.c
├── stm32f7
│ ├── Kconfig
│ ├── stm32f7.ld.in
│ ├── stm32f746discovery.c
│ ├── stm32f746nucleo-144.c
│ └── stm32f769discovery.c
├── string.c
├── string.h
├── sys.c
├── syscall_table_gen.py
├── syscall_vector.c
├── systick.c
├── tasklet.c
├── term.c
├── vfs.c
└── vfs.h
├── qemu.gdbinit
├── rules
├── arch.mk
├── config.mk
├── picotcp.mk
└── userspace.mk
├── scripts
├── frosted-dev-setup
└── frosted-qemu-setup
└── xipfs.h
/.gitignore:
--------------------------------------------------------------------------------
1 | # Object files
2 | *.o
3 | *.ko
4 | *.obj
5 | *.elf
6 | *.bin
7 |
8 | # Precompiled Headers
9 | *.gch
10 | *.pch
11 |
12 | # Libraries
13 | *.lib
14 | *.a
15 | *.la
16 | *.lo
17 |
18 | # Shared objects (inc. Windows DLLs)
19 | *.dll
20 | *.so
21 | *.so.*
22 | *.dylib
23 |
24 | # Executables
25 | *.exe
26 | *.out
27 | *.app
28 | *.i*86
29 | *.x86_64
30 | *.hex
31 | *.map
32 |
33 | # Debug files
34 | *.dSYM/
35 | *.lst
36 | *.d
37 | tags
38 |
39 | #python compiled
40 | *.pyc
41 |
42 | #kconfig
43 | kconfig/.config
44 | kconfig/.config.old
45 | kconfig/.depend
46 |
47 | #generated files
48 | apps/apps.ld
49 | .gdbinit
50 | build/
51 | kernel/syscall_table.c
52 | *.img
53 | *.ld
54 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "apps/busybox"]
2 | path = apps/busybox
3 | url = https://github.com/insane-adding-machines/busybox.git
4 | [submodule "kernel/net/picotcp"]
5 | path = kernel/net/picotcp
6 | url = https://github.com/danielinux/picotcp.git
7 | [submodule "frosted-userland"]
8 | path = frosted-userland
9 | url = https://github.com/insane-adding-machines/frosted-userland.git
10 | [submodule "kernel/frosted-headers"]
11 | path = kernel/frosted-headers
12 | url = https://github.com/insane-adding-machines/frosted-headers.git
13 | [submodule "kernel/unicore-mx"]
14 | path = kernel/unicore-mx
15 | url = https://github.com/insane-adding-machines/unicore-mx.git
16 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Frosted
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | org.eclipse.cdt.core.cnature
23 | org.eclipse.cdt.core.ccnature
24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | Code of Conduct
2 |
3 | Insane-adding-machines is a community organization, whose purpose is to promote the use of Free Software in the Internet of things.
4 |
5 | We value the involvement of everyone in this community. We are committed to creating a friendly and respectful place for learning, teaching and contributing. All participants in our events and communications are expected to show respect and courtesy to others.
6 |
7 | To make clear what is expected, everyone participating in activities within Insane-adding-machines is required to conform to the following Code of Conduct. This code of conduct applies to all spaces managed by Insane-adding-machines including, but not limited to, workshops, email lists, online forums, IRC channels and on GitHub.
8 |
9 | Code of Conduct
10 | ===============
11 |
12 | Insane-adding-machines are dedicated to providing a welcoming and supportive environment for all people, regardless of background or identity. However, we recognise that some groups in our community are subject to historical and ongoing discrimination, and may be vulnerable or disadvantaged. Membership in such a specific group can be on the basis of characteristics such as gender, sexual orientation, disability, physical appearance, body size, race, nationality, sex, colour, ethnic or social origin, pregnancy, citizenship, familial status, veteran status, genetic information, religion or belief, political or any other opinion, membership of a national minority, property, birth, age, or choice of text editor. We do not tolerate harassment of participants on the basis of these categories, or for any other reason.
13 |
14 | Harassment is any form of behaviour intended to exclude, intimidate, or cause discomfort. Because we are a diverse community, we may have different ways of communicating and of understanding the intent behind actions. Therefore we have chosen to prohibit certain forms of behaviour in our community, regardless of intent. Prohibited harassing behaviour includes but is not limited to:
15 |
16 | - written or verbal comments which have the effect of excluding people on the basis of membership of a specific group listed above
17 | causing someone to fear for their safety, such as through stalking, following, or intimidation
18 | - the display of sexual or violent images
19 | - unwelcome sexual attention
20 | - nonconsensual or unwelcome physical contact
21 | - sustained disruption of talks, events or communications
22 | - incitement to violence, suicide, or self-harm
23 | - continuing to initiate interaction (including photography or recording) with someone after being asked to stop
24 | - publication of private communication without consent
25 |
26 | Behaviour not explicitly mentioned above may still constitute harassment. The list above should not be taken as exhaustive but rather as a guide to make it easier to enrich all of us and the communities in which we participate. All interactions should be professional regardless of location: harassment is prohibited whether it occurs on- or offline, and the same standards apply to both.
27 |
28 | Enforcement of the Code of Conduct will be respectful and not include any harassing behaviors.
29 |
30 | Thank you for helping make this a welcoming, friendly community for all.
31 |
32 | This code of conduct is a modified version of that used by PyCon, which in turn is forked from a template written by the Ada Initiative and hosted on the Geek Feminism Wiki. Contributors to this document: Adam Obeng, Aleksandra Pawlik, Bill Mills, Carol Willing, Erin Becker, Hilmar Lapp, Kara Woo, Karin Lagesen, Pauline Barmby, Sheila Miguez, Simon Waldman, Tracy Teal.
33 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing to Frosted
2 | -----------------
3 |
4 | Frosted is a community project with no strong copyright enforcement.
5 | You are free to contribute to the official repository, hosted at
6 | github.com/insane-adding-machines/frosted.
7 |
8 | By contributing to Frosted, you agree that the code you write will be
9 | published and distributed under the term of GNU General Public License,
10 | as specified in LICENSE.
11 |
12 | We don't ask to yield any rights to the code you write, except those
13 | required by the LICENSE.
14 |
15 | In order to contribute, fork the project on github, commit in your local repository, submit a PR.
16 | Regular contributors that show interest for the projects are added to the community.
17 |
18 | Being part of the community means accepting the Code of Conduct.
19 |
20 | Coding style
21 | -----------------
22 |
23 | - Indentation is 4 spaces (no tabs)
24 | - no spaces inside parenthesis
25 | - spaces around binary operators
26 | - no trailing spaces
27 | - we place a space after every keyword
28 | - constants and macros are capitalized
29 | - the asterisk in a pointer declaration is adjacent to the symbol name, not its type
30 | - function opening brace is on the next line
31 | - inner blocks opening brace is on the same line
32 | - function/variable case default is `snake_case` and not `CamelCase`
33 | - no typedefs (exceptions must be discussed and approved by the community)
34 | - write short functions with meaningful names
35 | - centralized return point for functions is encouraged. The use of keyword `goto` is allowed to create a centralized return point.
36 |
37 | More in general, we appreciate if you follow the same style as the existing kernel code.
38 |
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Frosted :snowman:
2 |
3 | ## We moved to gitlab!
4 |
5 | Please visit [Frosted OS](https://gitlab.com/insane-adding-machines/frosted) and [Insane Adding Machines](https://gitlab.com/insane-adding-machines/) new homes!
6 |
7 | Bye!
8 |
9 | _the frosted development team_
10 |
--------------------------------------------------------------------------------
/defconfig/lpc1769.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | # ARCH_LM3S is not set
18 | ARCH_LPC17XX=y
19 | # ARCH_STM32F4 is not set
20 | # ARCH_STM32F7 is not set
21 | # ARCH_LPC1763 is not set
22 | # ARCH_LPC1764 is not set
23 | # ARCH_LPC1765 is not set
24 | # ARCH_LPC1766 is not set
25 | # ARCH_LPC1767 is not set
26 | # ARCH_LPC1768 is not set
27 | ARCH_LPC1769=y
28 | FLASH_SIZE_512KB=y
29 | RAM_SIZE_32KB=y
30 | # CLK_100MHZ is not set
31 | CLK_120MHZ=y
32 | MACH_LPC1679XPRESSO=y
33 |
34 | #
35 | # Kernel Configuration
36 | #
37 | KFLASHMEM_SIZE=128
38 | KRAMMEM_SIZE=32
39 | # TASK_STACK_SIZE_1K is not set
40 | TASK_STACK_SIZE_2K=y
41 | # TASK_STACK_SIZE_4K is not set
42 | # TASK_STACK_SIZE_8K is not set
43 | MPU=y
44 | PTHREADS=y
45 | SIGNALS=y
46 | PIPE=y
47 | # SOCK_UNIX is not set
48 |
49 | #
50 | # Debugging options
51 | #
52 | # KLOG is not set
53 | MEMFAULT_DBG=y
54 | # HARDFAULT_DBG is not set
55 | STRACE=y
56 |
57 | #
58 | # Filesystems
59 | #
60 | SYSFS=y
61 | MEMFS=y
62 | XIPFS=y
63 | # FATFS is not set
64 |
65 | #
66 | # Networking
67 | #
68 | # SOCK_INET is not set
69 | # TCPIP_MEMPOOL_YN is not set
70 |
71 | #
72 | # Device Drivers
73 | #
74 | # DEVNULL is not set
75 | DEVUART=y
76 | UART_0=y
77 | # UART_1 is not set
78 | # UART_2 is not set
79 | # UART_3 is not set
80 |
81 | #
82 | # Power Management
83 | #
84 |
85 | #
86 | # Power Management requires CPU Timer support
87 | #
88 |
--------------------------------------------------------------------------------
/defconfig/lpc17xx.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | # ARCH_LM3S is not set
18 | ARCH_LPC17XX=y
19 | # ARCH_STM32F4 is not set
20 | # ARCH_STM32F7 is not set
21 | # ARCH_LPC1763 is not set
22 | # ARCH_LPC1764 is not set
23 | # ARCH_LPC1765 is not set
24 | # ARCH_LPC1766 is not set
25 | # ARCH_LPC1767 is not set
26 | ARCH_LPC1768=y
27 | # ARCH_LPC1769 is not set
28 | FLASH_SIZE_512KB=y
29 | RAM_SIZE_32KB=y
30 | CLK_100MHZ=y
31 | # MACH_LPC1768MBED is not set
32 | MACH_SEEEDPRO=y
33 |
34 | #
35 | # Kernel Configuration
36 | #
37 | KFLASHMEM_SIZE=128
38 | KRAMMEM_SIZE=32
39 |
40 | #
41 | # IPC features
42 | #
43 | SIGNALS=y
44 | PIPE=y
45 | # SOCK_UNIX is not set
46 |
47 | #
48 | # Debugging options
49 | #
50 | # KLOG is not set
51 | MEMFAULT_DBG=y
52 | # HARDFAULT_DBG is not set
53 | STRACE=y
54 | # TASK_STACK_SIZE_1K is not set
55 | TASK_STACK_SIZE_2K=y
56 | # TASK_STACK_SIZE_4K is not set
57 | # TASK_STACK_SIZE_8K is not set
58 |
59 | #
60 | # Filesystems
61 | #
62 | SYSFS=y
63 | MEMFS=y
64 | XIPFS=y
65 | # FATFS is not set
66 |
67 | #
68 | # Networking
69 | #
70 | # SOCK_INET is not set
71 | # TCPIP_MEMPOOL_YN is not set
72 |
73 | #
74 | # Device Drivers
75 | #
76 | # DEVNULL is not set
77 | DEVUART=y
78 | UART_0=y
79 | # UART_1 is not set
80 | # UART_2 is not set
81 | # UART_3 is not set
82 | DEVGPIO=y
83 |
84 | #
85 | # Power Management
86 | #
87 |
88 | #
89 | # Power Management requires CPU Timer support
90 | #
91 |
--------------------------------------------------------------------------------
/defconfig/qemu-orig.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | ARCH_LM3S=y
18 | # ARCH_LPC17XX is not set
19 | # ARCH_STM32F4 is not set
20 | # ARCH_STM32F7 is not set
21 | ARCH_LM3S6965=y
22 | # ARCH_LM3SVIRT is not set
23 | FLASH_SIZE_256KB=y
24 | RAM_SIZE_64KB=y
25 | MACH_LM3S6965EVB=y
26 |
27 | #
28 | # Kernel Configuration
29 | #
30 | KFLASHMEM_SIZE=64
31 | KRAMMEM_SIZE=32
32 | # TASK_STACK_SIZE_1K is not set
33 | TASK_STACK_SIZE_2K=y
34 | # TASK_STACK_SIZE_4K is not set
35 | # TASK_STACK_SIZE_8K is not set
36 | MPU=y
37 |
38 | #
39 | # IPC features
40 | #
41 | SIGNALS=y
42 | PIPE=y
43 | # SOCK_UNIX is not set
44 |
45 | #
46 | # Debugging options
47 | #
48 | # KLOG is not set
49 | MEMFAULT_DBG=y
50 | # HARDFAULT_DBG is not set
51 | # STRACE is not set
52 |
53 | #
54 | # Filesystems
55 | #
56 | SYSFS=y
57 | # MEMFS is not set
58 | XIPFS=y
59 | # FATFS is not set
60 |
61 | #
62 | # Networking
63 | #
64 | # SOCK_INET is not set
65 | # TCPIP_MEMPOOL_YN is not set
66 |
67 | #
68 | # Device Drivers
69 | #
70 | # DEVNULL is not set
71 | DEVUART=y
72 | USART_0=y
73 | # USART_1 is not set
74 | # USART_2 is not set
75 |
76 | #
77 | # Power Management
78 | #
79 |
80 | #
81 | # Power Management requires CPU Timer support
82 | #
83 |
--------------------------------------------------------------------------------
/defconfig/qemu.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | ARCH_LM3S=y
18 | # ARCH_LPC17XX is not set
19 | # ARCH_STM32F4 is not set
20 | # ARCH_STM32F7 is not set
21 | # ARCH_LM3S6965 is not set
22 | ARCH_LM3SVIRT=y
23 | FLASH_SIZE_1MB=y
24 | RAM_SIZE_256KB=y
25 | MACH_LM3SVIRT=y
26 |
27 | #
28 | # Kernel Configuration
29 | #
30 | KFLASHMEM_SIZE=128
31 | KRAMMEM_SIZE=128
32 | # TASK_STACK_SIZE_1K is not set
33 | # TASK_STACK_SIZE_2K is not set
34 | TASK_STACK_SIZE_4K=y
35 | # TASK_STACK_SIZE_8K is not set
36 | MPU=y
37 | PTHREADS=y
38 | SIGNALS=y
39 | PIPE=y
40 | # SOCK_UNIX is not set
41 |
42 | #
43 | # Debugging options
44 | #
45 | # KLOG is not set
46 | MEMFAULT_DBG=y
47 | # HARDFAULT_DBG is not set
48 | # STRACE is not set
49 |
50 | #
51 | # Filesystems
52 | #
53 | SYSFS=y
54 | # MEMFS is not set
55 | XIPFS=y
56 | # FATFS is not set
57 |
58 | #
59 | # Networking
60 | #
61 | # SOCK_INET is not set
62 | # TCPIP_MEMPOOL_YN is not set
63 |
64 | #
65 | # Device Drivers
66 | #
67 | DEVNULL=y
68 | DEVUART=y
69 | USART_0=y
70 | # USART_1 is not set
71 | # USART_2 is not set
72 |
73 | #
74 | # Power Management
75 | #
76 |
77 | #
78 | # Power Management requires CPU Timer support
79 | #
80 |
--------------------------------------------------------------------------------
/defconfig/qemunet.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | ARCH_LM3S=y
18 | # ARCH_LPC17XX is not set
19 | # ARCH_STM32F4 is not set
20 | # ARCH_STM32F7 is not set
21 | # ARCH_LM3S6965 is not set
22 | ARCH_LM3SVIRT=y
23 | FLASH_SIZE_1MB=y
24 | RAM_SIZE_256KB=y
25 | MACH_LM3SVIRT=y
26 |
27 | #
28 | # Kernel Configuration
29 | #
30 | KFLASHMEM_SIZE=128
31 | KRAMMEM_SIZE=64
32 | # TASK_STACK_SIZE_1K is not set
33 | TASK_STACK_SIZE_2K=y
34 | # TASK_STACK_SIZE_4K is not set
35 | # TASK_STACK_SIZE_8K is not set
36 | MPU=y
37 | PTHREADS=y
38 | SIGNALS=y
39 | PIPE=y
40 | # SOCK_UNIX is not set
41 |
42 | #
43 | # Debugging options
44 | #
45 | # KLOG is not set
46 | MEMFAULT_DBG=y
47 | # HARDFAULT_DBG is not set
48 | # STRACE is not set
49 |
50 | #
51 | # Filesystems
52 | #
53 | SYSFS=y
54 | # MEMFS is not set
55 | XIPFS=y
56 | # FATFS is not set
57 |
58 | #
59 | # Networking
60 | #
61 | SOCK_INET=y
62 | # TCPIP_MEMPOOL_YN is not set
63 | PICOTCP=y
64 |
65 | #
66 | # picoTCP configuration
67 | #
68 | CONFIG_PICOTCP_IPV4=y
69 | # CONFIG_PICOTCP_IPV6 is not set
70 | CONFIG_PICOTCP_TCP=y
71 | CONFIG_PICOTCP_UDP=y
72 | CONFIG_PICOTCP_DNS=y
73 | # CONFIG_PICOTCP_MCAST is not set
74 | # CONFIG_PICOTCP_NAT is not set
75 | # CONFIG_PICOTCP_IPFILTER is not set
76 | CONFIG_PICOTCP_LOOP=y
77 | # CONFIG_PICOTCP_DEBUG is not set
78 |
79 | #
80 | # Device Drivers
81 | #
82 | DEVNULL=y
83 | DEVUART=y
84 | USART_0=y
85 | # USART_1 is not set
86 | # USART_2 is not set
87 | DEVLM3SETH=y
88 | ETH_DEFAULT_IP="192.168.20.150"
89 | ETH_DEFAULT_NM="255.255.255.0"
90 | ETH_DEFAULT_GW="192.168.20.1"
91 |
92 | #
93 | # Power Management
94 | #
95 |
96 | #
97 | # Power Management requires CPU Timer support
98 | #
99 |
--------------------------------------------------------------------------------
/defconfig/stm32f407-discovery.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | # ARCH_LM3S is not set
18 | # ARCH_LPC17XX is not set
19 | ARCH_STM32F4=y
20 | # ARCH_STM32F7 is not set
21 | # ARCH_STM32F401_XB is not set
22 | # ARCH_STM32F401_XC is not set
23 | # ARCH_STM32F401_XD is not set
24 | # ARCH_STM32F401_XE is not set
25 | # ARCH_STM32F405_XG is not set
26 | # ARCH_STM32F405_XE is not set
27 | ARCH_STM32F407_XG=y
28 | # ARCH_STM32F407_XE is not set
29 | # ARCH_STM32F411_XE is not set
30 | # ARCH_STM32F411_XC is not set
31 | # ARCH_STM32F429_XE is not set
32 | # ARCH_STM32F429_XG is not set
33 | # ARCH_STM32F429_XI is not set
34 | # ARCH_STM32F446_ZE is not set
35 | FLASH_SIZE_1MB=y
36 | RAM_SIZE_192KB=y
37 | ARCH_STM32F407=y
38 | DEVSTM32DMA=y
39 | # CLK_120MHZ is not set
40 | CLK_168MHZ=y
41 | MACH_STM32F407Discovery=y
42 | # STM32F4_SDRAM is not set
43 |
44 | #
45 | # Kernel Configuration
46 | #
47 | KFLASHMEM_SIZE=192
48 | KRAMMEM_SIZE=128
49 | # TASK_STACK_SIZE_1K is not set
50 | # TASK_STACK_SIZE_2K is not set
51 | TASK_STACK_SIZE_4K=y
52 | # TASK_STACK_SIZE_8K is not set
53 | MPU=y
54 | PTHREADS=y
55 | SIGNALS=y
56 | PIPE=y
57 | SOCK_UNIX=y
58 |
59 | #
60 | # Debugging options
61 | #
62 | # KLOG is not set
63 | MEMFAULT_DBG=y
64 | # HARDFAULT_DBG is not set
65 | # STRACE is not set
66 |
67 | #
68 | # Filesystems
69 | #
70 | SYSFS=y
71 | MEMFS=y
72 | XIPFS=y
73 | # FATFS is not set
74 |
75 | #
76 | # Networking
77 | #
78 | # SOCK_INET is not set
79 | # TCPIP_MEMPOOL_YN is not set
80 |
81 | #
82 | # Device Drivers
83 | #
84 | DEVNULL=y
85 | DEVUART=y
86 | # USART_1 is not set
87 | USART_2=y
88 | # USART_3 is not set
89 | # USART_6 is not set
90 | DEVF4DSP=y
91 | DEVSTM32USB=y
92 | DEVSTM32USBFS=y
93 | USBFS_HOST=y
94 | # USBFS_GUEST is not set
95 | # DEVTIM is not set
96 | # DEVADC is not set
97 | # DEVSTM32SDIO is not set
98 | # DEVSTM32I2C is not set
99 | # DEVSPI is not set
100 | # DEV_RANDOM is not set
101 | # DEVFRAMEBUFFER is not set
102 |
103 | #
104 | # Power Management
105 | #
106 |
107 | #
108 | # Power Management requires CPU Timer support
109 | #
110 |
--------------------------------------------------------------------------------
/defconfig/stm32f429i-discovery.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | # ARCH_LM3S is not set
18 | # ARCH_LPC17XX is not set
19 | ARCH_STM32F4=y
20 | # ARCH_STM32F7 is not set
21 | # ARCH_STM32F401_XB is not set
22 | # ARCH_STM32F401_XC is not set
23 | # ARCH_STM32F401_XD is not set
24 | # ARCH_STM32F401_XE is not set
25 | # ARCH_STM32F405_XG is not set
26 | # ARCH_STM32F405_XE is not set
27 | # ARCH_STM32F407_XG is not set
28 | # ARCH_STM32F407_XE is not set
29 | # ARCH_STM32F411_XE is not set
30 | # ARCH_STM32F411_XC is not set
31 | # ARCH_STM32F429_XE is not set
32 | # ARCH_STM32F429_XG is not set
33 | ARCH_STM32F429_XI=y
34 | # ARCH_STM32F446_ZE is not set
35 | FLASH_SIZE_2MB=y
36 | RAM_SIZE_256KB=y
37 | ARCH_STM32F429=y
38 | # CLK_48MHZ is not set
39 | # CLK_84MHZ is not set
40 | CLK_168MHZ=y
41 | MACH_STM32F429Discovery=y
42 |
43 | #
44 | # Kernel Configuration
45 | #
46 | KFLASHMEM_SIZE=128
47 | KRAMMEM_SIZE=64
48 | # TASK_STACK_SIZE_1K is not set
49 | TASK_STACK_SIZE_2K=y
50 | # TASK_STACK_SIZE_4K is not set
51 | # TASK_STACK_SIZE_8K is not set
52 | MPU=y
53 |
54 | #
55 | # IPC features
56 | #
57 | SIGNALS=y
58 | PIPE=y
59 | # SOCK_UNIX is not set
60 |
61 | #
62 | # Debugging options
63 | #
64 | KLOG=y
65 | KLOG_SIZE=256
66 | MEMFAULT_DBG=y
67 | # HARDFAULT_DBG is not set
68 | # STRACE is not set
69 |
70 | #
71 | # Filesystems
72 | #
73 | SYSFS=y
74 | MEMFS=y
75 | XIPFS=y
76 | # FATFS is not set
77 |
78 | #
79 | # Networking
80 | #
81 | # SOCK_INET is not set
82 | # TCPIP_MEMPOOL_YN is not set
83 |
84 | #
85 | # Device Drivers
86 | #
87 | DEVNULL=y
88 | DEVUART=y
89 | USART_1=y
90 | # USART_2 is not set
91 | # DEVF4DSP is not set
92 | # DEVSTM32USB is not set
93 | # DEVTIM is not set
94 | # DEVADC is not set
95 | # DEVSTM32SDIO is not set
96 | # DEVSTM32I2C is not set
97 | # DEVSPI is not set
98 | # DEV_RANDOM is not set
99 | # DEVRNG is not set
100 | # DEVFRAND is not set
101 |
102 | #
103 | # Power Management
104 | #
105 |
106 | #
107 | # Power Management requires CPU Timer support
108 | #
109 |
--------------------------------------------------------------------------------
/defconfig/stm32f746-discovery.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | # ARCH_LM3S is not set
18 | # ARCH_LPC17XX is not set
19 | # ARCH_STM32F4 is not set
20 | ARCH_STM32F7=y
21 | ARCH_STM32F746_NG=y
22 | # ARCH_STM32F769_NI is not set
23 | FLASH_SIZE_1MB=y
24 | RAM_SIZE_320KB=y
25 | ARCH_STM32F746=y
26 | CLK_216MHZ=y
27 | MACH_STM32F746Discovery=y
28 | # MACH_STM32F746Nucleo144 is not set
29 | STM32F7_SDRAM=y
30 |
31 | #
32 | # Kernel Configuration
33 | #
34 | KFLASHMEM_SIZE=256
35 | KRAMMEM_SIZE=256
36 | # TASK_STACK_SIZE_1K is not set
37 | # TASK_STACK_SIZE_2K is not set
38 | TASK_STACK_SIZE_4K=y
39 | # TASK_STACK_SIZE_8K is not set
40 | MPU=y
41 | PTHREADS=y
42 | SIGNALS=y
43 | PIPE=y
44 | # SOCK_UNIX is not set
45 |
46 | #
47 | # Debugging options
48 | #
49 | # KLOG is not set
50 | MEMFAULT_DBG=y
51 | # HARDFAULT_DBG is not set
52 | STRACE=y
53 |
54 | #
55 | # Filesystems
56 | #
57 | SYSFS=y
58 | # MEMFS is not set
59 | XIPFS=y
60 | FATFS=y
61 | FAT32=y
62 | FAT16=y
63 |
64 | #
65 | # Networking
66 | #
67 | SOCK_INET=y
68 | # TCPIP_MEMPOOL_YN is not set
69 | PICOTCP=y
70 |
71 | #
72 | # picoTCP configuration
73 | #
74 | CONFIG_PICOTCP_IPV4=y
75 | # CONFIG_PICOTCP_IPV6 is not set
76 | CONFIG_PICOTCP_TCP=y
77 | CONFIG_PICOTCP_UDP=y
78 | CONFIG_PICOTCP_DNS=y
79 | # CONFIG_PICOTCP_MCAST is not set
80 | # CONFIG_PICOTCP_NAT is not set
81 | # CONFIG_PICOTCP_IPFILTER is not set
82 | CONFIG_PICOTCP_LOOP=y
83 | # CONFIG_PICOTCP_DEBUG is not set
84 |
85 | #
86 | # Device Drivers
87 | #
88 | DEVNULL=y
89 | DEVUART=y
90 | # USART_1 is not set
91 | # USART_2 is not set
92 | # USART_3 is not set
93 | USART_6=y
94 | DEVSTM32USB=y
95 | DEVSTM32USBFS=y
96 | # USBFS_HOST is not set
97 | USBFS_GUEST=y
98 | # DEVSTM32USBHS is not set
99 | DEV_USB_ETH=y
100 | USB_DEFAULT_IP="192.168.6.150"
101 | USB_DEFAULT_NM="255.255.255.0"
102 | USB_DEFAULT_GW="192.168.6.1"
103 | # DEVTIM is not set
104 | # DEVF7ETH is not set
105 | DEVSTM32SDIO=y
106 | # DEVSTM32I2C is not set
107 | # DEVSPI is not set
108 | # DEV_RANDOM is not set
109 | DEVFRAMEBUFFER=y
110 | DEVFBCON=y
111 | FONT_CGA_8X8=y
112 | # FONT_PICCOLO_7X6 is not set
113 | DEVF7DISCOLTDC=y
114 |
115 | #
116 | # Power Management
117 | #
118 |
119 | #
120 | # Power Management requires CPU Timer support
121 | #
122 |
--------------------------------------------------------------------------------
/defconfig/stm32f746-nucleo.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | # ARCH_LM3S is not set
18 | # ARCH_LPC17XX is not set
19 | # ARCH_STM32F4 is not set
20 | ARCH_STM32F7=y
21 | ARCH_STM32F746_NG=y
22 | # ARCH_STM32F769_NI is not set
23 | FLASH_SIZE_1MB=y
24 | RAM_SIZE_320KB=y
25 | ARCH_STM32F746=y
26 | CLK_216MHZ=y
27 | # MACH_STM32F746Discovery is not set
28 | MACH_STM32F746Nucleo144=y
29 | # STM32F7_SDRAM is not set
30 |
31 | #
32 | # Kernel Configuration
33 | #
34 | KFLASHMEM_SIZE=128
35 | KRAMMEM_SIZE=32
36 | # TASK_STACK_SIZE_1K is not set
37 | TASK_STACK_SIZE_2K=y
38 | # TASK_STACK_SIZE_4K is not set
39 | # TASK_STACK_SIZE_8K is not set
40 | MPU=y
41 | PTHREADS=y
42 | SIGNALS=y
43 | PIPE=y
44 | # SOCK_UNIX is not set
45 |
46 | #
47 | # Debugging options
48 | #
49 | # KLOG is not set
50 | MEMFAULT_DBG=y
51 | # HARDFAULT_DBG is not set
52 | STRACE=y
53 |
54 | #
55 | # Filesystems
56 | #
57 | SYSFS=y
58 | # MEMFS is not set
59 | XIPFS=y
60 | # FATFS is not set
61 |
62 | #
63 | # Networking
64 | #
65 | # SOCK_INET is not set
66 | # TCPIP_MEMPOOL_YN is not set
67 |
68 | #
69 | # Device Drivers
70 | #
71 | DEVNULL=y
72 | DEVUART=y
73 | # USART_1 is not set
74 | # USART_2 is not set
75 | # USART_3 is not set
76 | USART_6=y
77 | DEVSTM32USB=y
78 | DEVSTM32USBFS=y
79 | USBFS_HOST=y
80 | # USBFS_GUEST is not set
81 | # DEVSTM32USBHS is not set
82 | # DEVTIM is not set
83 | # DEVSTM32SDIO is not set
84 | # DEVSTM32I2C is not set
85 | # DEVSPI is not set
86 | # DEV_RANDOM is not set
87 | # DEVFRAMEBUFFER is not set
88 |
89 | #
90 | # Power Management
91 | #
92 |
93 | #
94 | # Power Management requires CPU Timer support
95 | #
96 |
--------------------------------------------------------------------------------
/defconfig/stm32f769-discovery.config:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Compiler options
8 | #
9 | GDB_CFLAG=y
10 | OPTIMIZE_NONE=y
11 | # OPTIMIZE_SIZE is not set
12 | # OPTIMIZE_PERF is not set
13 |
14 | #
15 | # Platform Selection
16 | #
17 | # ARCH_LM3S is not set
18 | # ARCH_LPC17XX is not set
19 | # ARCH_STM32F4 is not set
20 | ARCH_STM32F7=y
21 | # ARCH_NRF51 is not set
22 | # ARCH_STM32F746_NG is not set
23 | ARCH_STM32F769_NI=y
24 | FLASH_SIZE_2MB=y
25 | RAM_SIZE_368KB=y
26 | ARCH_STM32F769=y
27 | CLK_216MHZ=y
28 | MACH_STM32F769Discovery=y
29 | # STM32F7_SDRAM is not set
30 |
31 | #
32 | # Kernel Configuration
33 | #
34 | KFLASHMEM_SIZE=128
35 | KRAMMEM_SIZE=64
36 | # TASK_STACK_SIZE_1K is not set
37 | # TASK_STACK_SIZE_2K is not set
38 | TASK_STACK_SIZE_4K=y
39 | # TASK_STACK_SIZE_8K is not set
40 | MPU=y
41 | PTHREADS=y
42 | SIGNALS=y
43 | PIPE=y
44 | # SOCK_UNIX is not set
45 |
46 | #
47 | # Debugging options
48 | #
49 | KLOG=y
50 | KLOG_SIZE=256
51 | MEMFAULT_DBG=y
52 | HARDFAULT_DBG=y
53 | # STRACE is not set
54 |
55 | #
56 | # Filesystems
57 | #
58 | SYSFS=y
59 | MEMFS=y
60 | XIPFS=y
61 | FATFS=y
62 | FAT32=y
63 | FAT16=y
64 |
65 | #
66 | # Networking
67 | #
68 | SOCK_INET=y
69 | # TCPIP_MEMPOOL_YN is not set
70 | PICOTCP=y
71 |
72 | #
73 | # picoTCP configuration
74 | #
75 | CONFIG_PICOTCP_IPV4=y
76 | # CONFIG_PICOTCP_IPV6 is not set
77 | CONFIG_PICOTCP_TCP=y
78 | CONFIG_PICOTCP_UDP=y
79 | CONFIG_PICOTCP_DNS=y
80 | # CONFIG_PICOTCP_MCAST is not set
81 | # CONFIG_PICOTCP_NAT is not set
82 | # CONFIG_PICOTCP_IPFILTER is not set
83 | CONFIG_PICOTCP_LOOP=y
84 | # CONFIG_PICOTCP_DEBUG is not set
85 |
86 | #
87 | # Device Drivers
88 | #
89 | DEVNULL=y
90 | DEVUART=y
91 | # USART_1 is not set
92 | # USART_2 is not set
93 | # USART_3 is not set
94 | USART_6=y
95 | # DEVSTM32USBHS is not set
96 | DEVF7ETH=y
97 | ETH_DEFAULT_IP="192.168.2.151"
98 | ETH_DEFAULT_NM="255.255.255.0"
99 | ETH_DEFAULT_GW="192.168.2.1"
100 | DEVSTM32SDIO=y
101 | # DEVSPI is not set
102 | # DEV_RANDOM is not set
103 | # DEVFRAMEBUFFER is not set
104 |
105 | #
106 | # Power Management
107 | #
108 |
109 | #
110 | # Power Management requires CPU Timer support
111 | #
112 |
--------------------------------------------------------------------------------
/gdbinit.bflt:
--------------------------------------------------------------------------------
1 | tar ext :3333
2 | monitor reset
3 | layout src
4 | symbol-file
5 | file kernel.elf
6 | add-symbol-file ./frosted-mini-userspace-bflt/init.gdb 0x20090 -s .data 0x20008014 -s .bss 0x2000813c
7 | add-symbol-file frosted-mini-userspace-bflt/idling.gdb 0x20a84 -s .data 0x2000815c -s .bss 0x200081ac
8 | add-symbol-file frosted-mini-userspace-bflt/fresh.gdb 0x21334 -s .data 0x200081f8 -s .bss 0x20008b84
9 | add-symbol-file frosted-mini-userspace-bflt/binutils.gdb 0x18de0 -s .data 0x2000acf0 -s .bss 0x2000c610
10 | mon reset
11 | mon halt
12 | stepi
13 | focus c
14 |
--------------------------------------------------------------------------------
/gdbinit.mini:
--------------------------------------------------------------------------------
1 | tar ext :3333
2 | monitor reset
3 | layout src
4 | symbol-file
5 | file kernel.elf
6 | mon reset
7 | mon halt
8 | stepi
9 | focus c
10 |
--------------------------------------------------------------------------------
/include/frosted_api.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_FROSTED_API
2 | #define INC_FROSTED_API
3 | #include "stdint.h"
4 |
5 | #define INIT __attribute__((section(".init")))
6 |
7 | /* Constants */
8 |
9 | /* move to limits.h ? */
10 | #define MAXPATHLEN 256
11 | #define ARG_MAX 32
12 |
13 |
14 | /* open */
15 | #include
16 |
17 |
18 | /* seek */
19 | #define SEEK_SET 0
20 | #define SEEK_CUR 1
21 | #define SEEK_END 2
22 |
23 | /* syslog */
24 | #define LOG_EMERG 0 /* system is unusable */
25 | #define LOG_ALERT 1 /* action must be taken immediately */
26 | #define LOG_CRIT 2 /* critical conditions */
27 | #define LOG_ERR 3 /* error conditions */
28 | #define LOG_WARNING 4 /* warning conditions */
29 | #define LOG_NOTICE 5 /* normal but significant condition */
30 | #define LOG_INFO 6 /* informational */
31 | #define LOG_DEBUG 7 /* debug-level messages */
32 |
33 |
34 | /* opendir - readdir */
35 | typedef void DIR;
36 |
37 | /* semaphore */
38 | struct semaphore;
39 | typedef struct semaphore sem_t;
40 | typedef struct semaphore mutex_t;
41 |
42 | #define MAX_FILE 64
43 | struct dirent {
44 | uint32_t d_ino;
45 | char d_name[MAX_FILE];
46 | };
47 |
48 | /*
49 | #define S_IFMT 0170000 // bit mask for the file type bit fields
50 | #define P_IFMT 0000007 // bit mask for file permissions
51 | */
52 |
53 | #define P_EXEC 0000001 // exec
54 |
55 |
56 | /* for unix sockets */
57 | #ifndef __frosted__
58 | #define AF_UNIX 0
59 | #define SOCK_STREAM 6
60 | #define SOCK_DGRAM 17
61 | #endif
62 |
63 | struct __attribute__((packed)) sockaddr {
64 | uint16_t sa_family;
65 | uint8_t sa_zero[14];
66 | };
67 |
68 | struct __attribute__((packed)) sockaddr_un {
69 | uint16_t sun_family;
70 | uint8_t sun_path[MAX_FILE - 2];
71 | };
72 |
73 | struct sockaddr_env {
74 | struct sockaddr *se_addr;
75 | unsigned int se_len;
76 | };
77 |
78 | extern int errno;
79 |
80 | #endif
81 |
--------------------------------------------------------------------------------
/kconfig/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # Generated files
3 | #
4 | config*
5 | *.lex.c
6 | *.tab.c
7 | *.tab.h
8 | zconf.hash.c
9 | *.moc
10 | gconf.glade.h
11 | *.pot
12 | *.mo
13 |
14 | #
15 | # configuration programs
16 | #
17 | conf
18 | mconf
19 | nconf
20 | qconf
21 | gconf
22 | kxgettext
23 |
--------------------------------------------------------------------------------
/kconfig/Kconfig:
--------------------------------------------------------------------------------
1 | mainmenu "FROSTED Kernel Configuration"
2 | source ../kernel/Kconfig
3 |
4 |
5 |
--------------------------------------------------------------------------------
/kconfig/Makefile.frosted:
--------------------------------------------------------------------------------
1 | src := .
2 | top_srcdir=../../
3 | top_builddir=../../
4 | srctree := .
5 | obj ?= .
6 |
7 | include Makefile
8 | #HOSTCFLAGS+=-Dinline="" -include foo.h
9 |
10 | #CFLAGS+=-DCURSES_LOC=""
11 | #CFLAGS+=-DLOCALE
12 | HOSTCC?=gcc
13 | PATH:=$(PATH):.
14 |
15 | -include $(obj)/.depend
16 | $(obj)/.depend: $(wildcard *.h *.c)
17 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > $@ 2>/dev/null || :
18 |
19 | __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
20 | host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
21 | host-cmulti := $(foreach m,$(__hostprogs),\
22 | $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
23 | host-cxxmulti := $(foreach m,$(__hostprogs),\
24 | $(if $($(m)-cxxobjs),$(m),$(if $($(m)-objs),)))
25 | host-cobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-objs))))
26 | host-cxxobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-cxxobjs))))
27 |
28 | HOST_EXTRACFLAGS += -I$(obj) -DCONFIG_=\"\"
29 |
30 | $(host-csingle): %: %.c
31 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $< -o $(obj)/$@
32 |
33 | $(host-cmulti): %: $(host-cobjs) $(host-cshlib)
34 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$@) $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F)) -o $(obj)/$@
35 |
36 | $(host-cxxmulti): %: $(host-cxxobjs) $(host-cobjs) $(host-cshlib)
37 | $(HOSTCXX) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$@) $(addprefix $(obj)/,$($(@F)-objs) $($(@F)-cxxobjs)) $(HOSTLOADLIBES_$(@F)) -o $(obj)/$@
38 |
39 | $(obj)/%.o: %.c
40 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@
41 |
42 | $(obj)/%.o: $(obj)/%.c
43 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@
44 |
45 | $(obj)/%.o: %.cc
46 | $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) -c $< -o $@
47 |
48 | $(obj)/%:: $(src)/%_shipped
49 | $(Q)cat $< > $@
50 |
51 | clean:
52 | $(Q)rm -f $(addprefix $(obj)/,$(clean-files))
53 | distclean: clean
54 | $(Q)rm -f $(addprefix $(obj)/,$(lxdialog) $(conf-objs) $(mconf-objs) $(kxgettext-objs) \
55 | $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \
56 | mconf .depend)
57 |
58 | FORCE:
59 | .PHONY: FORCE clean distclean
60 |
--------------------------------------------------------------------------------
/kconfig/POTFILES.in:
--------------------------------------------------------------------------------
1 | scripts/kconfig/lxdialog/checklist.c
2 | scripts/kconfig/lxdialog/inputbox.c
3 | scripts/kconfig/lxdialog/menubox.c
4 | scripts/kconfig/lxdialog/textbox.c
5 | scripts/kconfig/lxdialog/util.c
6 | scripts/kconfig/lxdialog/yesno.c
7 | scripts/kconfig/mconf.c
8 | scripts/kconfig/conf.c
9 | scripts/kconfig/confdata.c
10 | scripts/kconfig/gconf.c
11 | scripts/kconfig/gconf.glade.h
12 | scripts/kconfig/qconf.cc
13 |
--------------------------------------------------------------------------------
/kconfig/STM32F4x1Discovery.cfg:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Platform Selection
8 | #
9 | # ARCH_LM3S is not set
10 | # ARCH_LPC17XX is not set
11 | ARCH_STM32F4=y
12 | # ARCH_STM32F401_XB is not set
13 | # ARCH_STM32F401_XC is not set
14 | # ARCH_STM32F401_XD is not set
15 | # ARCH_STM32F401_XE is not set
16 | # ARCH_STM32F405_XG is not set
17 | # ARCH_STM32F405_XE is not set
18 | # ARCH_STM32F407_XG is not set
19 | # ARCH_STM32F407_XE is not set
20 | ARCH_STM32F411_XE=y
21 | # ARCH_STM32F411_XC is not set
22 | # ARCH_STM32F429_XE is not set
23 | # ARCH_STM32F429_XG is not set
24 | # ARCH_STM32F429_XI is not set
25 | FLASH_SIZE_512KB=y
26 | RAM_SIZE_128KB=y
27 | ARCH_STM32F411=y
28 | CLK_48MHZ=y
29 | # CLK_84MHZ is not set
30 | MACH_STM32F4x1Discovery=y
31 |
32 | #
33 | # Kernel Configuration
34 | #
35 | KFLASHMEM_SIZE=48
36 | KRAMMEM_SIZE=16
37 |
38 | #
39 | # Subsystems
40 | #
41 |
42 | #
43 | # Filesystems
44 | #
45 | SYSFS=y
46 | MEMFS=y
47 | XIPFS=y
48 |
49 | #
50 | # Sockets
51 | #
52 | SOCK_UNIX=y
53 |
54 | #
55 | # Devices
56 | #
57 | DEVNULL=y
58 | DEVUART=y
59 | # USART_1 is not set
60 | USART_2=y
61 | # USART_6 is not set
62 | DEVSPI=y
63 | SPI_1=y
64 | DEVL3GD20=y
65 | DEVGPIO=y
66 |
67 | #
68 | # Applications
69 | #
70 | FRESH=y
71 | # TASK2 is not set
72 | # PRODCONS is not set
73 |
--------------------------------------------------------------------------------
/kconfig/check.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Needed for systems without gettext
3 | $* -x c -o /dev/null - > /dev/null 2>&1 << EOF
4 | #include
5 | int main()
6 | {
7 | gettext("");
8 | return 0;
9 | }
10 | EOF
11 | if [ ! "$?" -eq "0" ]; then
12 | echo -DKBUILD_NO_NLS;
13 | fi
14 |
15 |
--------------------------------------------------------------------------------
/kconfig/frosted.conf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insane-adding-machines/frosted/5c3aa21f146a1b840badfd72d1d8b96e8405a8d8/kconfig/frosted.conf
--------------------------------------------------------------------------------
/kconfig/kxgettext.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Arnaldo Carvalho de Melo , 2005
3 | *
4 | * Released under the terms of the GNU GPL v2.0
5 | */
6 |
7 | #include
8 | #include
9 |
10 | #include "lkc.h"
11 |
12 | static char *escape(const char* text, char *bf, int len)
13 | {
14 | char *bfp = bf;
15 | int multiline = strchr(text, '\n') != NULL;
16 | int eol = 0;
17 | int textlen = strlen(text);
18 |
19 | if ((textlen > 0) && (text[textlen-1] == '\n'))
20 | eol = 1;
21 |
22 | *bfp++ = '"';
23 | --len;
24 |
25 | if (multiline) {
26 | *bfp++ = '"';
27 | *bfp++ = '\n';
28 | *bfp++ = '"';
29 | len -= 3;
30 | }
31 |
32 | while (*text != '\0' && len > 1) {
33 | if (*text == '"')
34 | *bfp++ = '\\';
35 | else if (*text == '\n') {
36 | *bfp++ = '\\';
37 | *bfp++ = 'n';
38 | *bfp++ = '"';
39 | *bfp++ = '\n';
40 | *bfp++ = '"';
41 | len -= 5;
42 | ++text;
43 | goto next;
44 | }
45 | else if (*text == '\\') {
46 | *bfp++ = '\\';
47 | len--;
48 | }
49 | *bfp++ = *text++;
50 | next:
51 | --len;
52 | }
53 |
54 | if (multiline && eol)
55 | bfp -= 3;
56 |
57 | *bfp++ = '"';
58 | *bfp = '\0';
59 |
60 | return bf;
61 | }
62 |
63 | struct file_line {
64 | struct file_line *next;
65 | const char *file;
66 | int lineno;
67 | };
68 |
69 | static struct file_line *file_line__new(const char *file, int lineno)
70 | {
71 | struct file_line *self = malloc(sizeof(*self));
72 |
73 | if (self == NULL)
74 | goto out;
75 |
76 | self->file = file;
77 | self->lineno = lineno;
78 | self->next = NULL;
79 | out:
80 | return self;
81 | }
82 |
83 | struct message {
84 | const char *msg;
85 | const char *option;
86 | struct message *next;
87 | struct file_line *files;
88 | };
89 |
90 | static struct message *message__list;
91 |
92 | static struct message *message__new(const char *msg, char *option,
93 | const char *file, int lineno)
94 | {
95 | struct message *self = malloc(sizeof(*self));
96 |
97 | if (self == NULL)
98 | goto out;
99 |
100 | self->files = file_line__new(file, lineno);
101 | if (self->files == NULL)
102 | goto out_fail;
103 |
104 | self->msg = strdup(msg);
105 | if (self->msg == NULL)
106 | goto out_fail_msg;
107 |
108 | self->option = option;
109 | self->next = NULL;
110 | out:
111 | return self;
112 | out_fail_msg:
113 | free(self->files);
114 | out_fail:
115 | free(self);
116 | self = NULL;
117 | goto out;
118 | }
119 |
120 | static struct message *mesage__find(const char *msg)
121 | {
122 | struct message *m = message__list;
123 |
124 | while (m != NULL) {
125 | if (strcmp(m->msg, msg) == 0)
126 | break;
127 | m = m->next;
128 | }
129 |
130 | return m;
131 | }
132 |
133 | static int message__add_file_line(struct message *self, const char *file,
134 | int lineno)
135 | {
136 | int rc = -1;
137 | struct file_line *fl = file_line__new(file, lineno);
138 |
139 | if (fl == NULL)
140 | goto out;
141 |
142 | fl->next = self->files;
143 | self->files = fl;
144 | rc = 0;
145 | out:
146 | return rc;
147 | }
148 |
149 | static int message__add(const char *msg, char *option, const char *file,
150 | int lineno)
151 | {
152 | int rc = 0;
153 | char bf[16384];
154 | char *escaped = escape(msg, bf, sizeof(bf));
155 | struct message *m = mesage__find(escaped);
156 |
157 | if (m != NULL)
158 | rc = message__add_file_line(m, file, lineno);
159 | else {
160 | m = message__new(escaped, option, file, lineno);
161 |
162 | if (m != NULL) {
163 | m->next = message__list;
164 | message__list = m;
165 | } else
166 | rc = -1;
167 | }
168 | return rc;
169 | }
170 |
171 | static void menu_build_message_list(struct menu *menu)
172 | {
173 | struct menu *child;
174 |
175 | message__add(menu_get_prompt(menu), NULL,
176 | menu->file == NULL ? "Root Menu" : menu->file->name,
177 | menu->lineno);
178 |
179 | if (menu->sym != NULL && menu_has_help(menu))
180 | message__add(menu_get_help(menu), menu->sym->name,
181 | menu->file == NULL ? "Root Menu" : menu->file->name,
182 | menu->lineno);
183 |
184 | for (child = menu->list; child != NULL; child = child->next)
185 | if (child->prompt != NULL)
186 | menu_build_message_list(child);
187 | }
188 |
189 | static void message__print_file_lineno(struct message *self)
190 | {
191 | struct file_line *fl = self->files;
192 |
193 | putchar('\n');
194 | if (self->option != NULL)
195 | printf("# %s:00000\n", self->option);
196 |
197 | printf("#: %s:%d", fl->file, fl->lineno);
198 | fl = fl->next;
199 |
200 | while (fl != NULL) {
201 | printf(", %s:%d", fl->file, fl->lineno);
202 | fl = fl->next;
203 | }
204 |
205 | putchar('\n');
206 | }
207 |
208 | static void message__print_gettext_msgid_msgstr(struct message *self)
209 | {
210 | message__print_file_lineno(self);
211 |
212 | printf("msgid %s\n"
213 | "msgstr \"\"\n", self->msg);
214 | }
215 |
216 | static void menu__xgettext(void)
217 | {
218 | struct message *m = message__list;
219 |
220 | while (m != NULL) {
221 | /* skip empty lines ("") */
222 | if (strlen(m->msg) > sizeof("\"\""))
223 | message__print_gettext_msgid_msgstr(m);
224 | m = m->next;
225 | }
226 | }
227 |
228 | int main(int ac, char **av)
229 | {
230 | conf_parse(av[1]);
231 |
232 | menu_build_message_list(menu_get_root_menu(NULL));
233 | menu__xgettext();
234 | return 0;
235 | }
236 |
--------------------------------------------------------------------------------
/kconfig/list.h:
--------------------------------------------------------------------------------
1 | #ifndef LIST_H
2 | #define LIST_H
3 |
4 | /*
5 | * Copied from include/linux/...
6 | */
7 |
8 | #undef offsetof
9 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
10 |
11 | /**
12 | * container_of - cast a member of a structure out to the containing structure
13 | * @ptr: the pointer to the member.
14 | * @type: the type of the container struct this is embedded in.
15 | * @member: the name of the member within the struct.
16 | *
17 | */
18 | #define container_of(ptr, type, member) ({ \
19 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \
20 | (type *)( (char *)__mptr - offsetof(type,member) );})
21 |
22 |
23 | struct list_head {
24 | struct list_head *next, *prev;
25 | };
26 |
27 |
28 | #define LIST_HEAD_INIT(name) { &(name), &(name) }
29 |
30 | #define LIST_HEAD(name) \
31 | struct list_head name = LIST_HEAD_INIT(name)
32 |
33 | /**
34 | * list_entry - get the struct for this entry
35 | * @ptr: the &struct list_head pointer.
36 | * @type: the type of the struct this is embedded in.
37 | * @member: the name of the list_struct within the struct.
38 | */
39 | #define list_entry(ptr, type, member) \
40 | container_of(ptr, type, member)
41 |
42 | /**
43 | * list_for_each_entry - iterate over list of given type
44 | * @pos: the type * to use as a loop cursor.
45 | * @head: the head for your list.
46 | * @member: the name of the list_struct within the struct.
47 | */
48 | #define list_for_each_entry(pos, head, member) \
49 | for (pos = list_entry((head)->next, typeof(*pos), member); \
50 | &pos->member != (head); \
51 | pos = list_entry(pos->member.next, typeof(*pos), member))
52 |
53 | /**
54 | * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
55 | * @pos: the type * to use as a loop cursor.
56 | * @n: another type * to use as temporary storage
57 | * @head: the head for your list.
58 | * @member: the name of the list_struct within the struct.
59 | */
60 | #define list_for_each_entry_safe(pos, n, head, member) \
61 | for (pos = list_entry((head)->next, typeof(*pos), member), \
62 | n = list_entry(pos->member.next, typeof(*pos), member); \
63 | &pos->member != (head); \
64 | pos = n, n = list_entry(n->member.next, typeof(*n), member))
65 |
66 | /**
67 | * list_empty - tests whether a list is empty
68 | * @head: the list to test.
69 | */
70 | static inline int list_empty(const struct list_head *head)
71 | {
72 | return head->next == head;
73 | }
74 |
75 | /*
76 | * Insert a new entry between two known consecutive entries.
77 | *
78 | * This is only for internal list manipulation where we know
79 | * the prev/next entries already!
80 | */
81 | static inline void __list_add(struct list_head *_new,
82 | struct list_head *prev,
83 | struct list_head *next)
84 | {
85 | next->prev = _new;
86 | _new->next = next;
87 | _new->prev = prev;
88 | prev->next = _new;
89 | }
90 |
91 | /**
92 | * list_add_tail - add a new entry
93 | * @new: new entry to be added
94 | * @head: list head to add it before
95 | *
96 | * Insert a new entry before the specified head.
97 | * This is useful for implementing queues.
98 | */
99 | static inline void list_add_tail(struct list_head *_new, struct list_head *head)
100 | {
101 | __list_add(_new, head->prev, head);
102 | }
103 |
104 | /*
105 | * Delete a list entry by making the prev/next entries
106 | * point to each other.
107 | *
108 | * This is only for internal list manipulation where we know
109 | * the prev/next entries already!
110 | */
111 | static inline void __list_del(struct list_head *prev, struct list_head *next)
112 | {
113 | next->prev = prev;
114 | prev->next = next;
115 | }
116 |
117 | #define LIST_POISON1 ((void *) 0x00100100)
118 | #define LIST_POISON2 ((void *) 0x00200200)
119 | /**
120 | * list_del - deletes entry from list.
121 | * @entry: the element to delete from the list.
122 | * Note: list_empty() on entry does not return true after this, the entry is
123 | * in an undefined state.
124 | */
125 | static inline void list_del(struct list_head *entry)
126 | {
127 | __list_del(entry->prev, entry->next);
128 | entry->next = (struct list_head*)LIST_POISON1;
129 | entry->prev = (struct list_head*)LIST_POISON2;
130 | }
131 | #endif
132 |
--------------------------------------------------------------------------------
/kconfig/lkc_proto.h:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | /* confdata.c */
4 | P(conf_parse,void,(const char *name));
5 | P(conf_read,int,(const char *name));
6 | P(conf_read_simple,int,(const char *name, int));
7 | P(conf_write_defconfig,int,(const char *name));
8 | P(conf_write,int,(const char *name));
9 | P(conf_write_autoconf,int,(void));
10 | P(conf_get_changed,bool,(void));
11 | P(conf_set_changed_callback, void,(void (*fn)(void)));
12 | P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
13 |
14 | /* menu.c */
15 | P(rootmenu,struct menu,);
16 |
17 | P(menu_is_empty, bool, (struct menu *menu));
18 | P(menu_is_visible, bool, (struct menu *menu));
19 | P(menu_has_prompt, bool, (struct menu *menu));
20 | P(menu_get_prompt,const char *,(struct menu *menu));
21 | P(menu_get_root_menu,struct menu *,(struct menu *menu));
22 | P(menu_get_parent_menu,struct menu *,(struct menu *menu));
23 | P(menu_has_help,bool,(struct menu *menu));
24 | P(menu_get_help,const char *,(struct menu *menu));
25 | P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
26 | *head));
27 | P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
28 | *head));
29 | P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
30 |
31 | /* symbol.c */
32 | P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]);
33 |
34 | P(sym_lookup,struct symbol *,(const char *name, int flags));
35 | P(sym_find,struct symbol *,(const char *name));
36 | P(sym_expand_string_value,const char *,(const char *in));
37 | P(sym_escape_string_value, const char *,(const char *in));
38 | P(sym_re_search,struct symbol **,(const char *pattern));
39 | P(sym_type_name,const char *,(enum symbol_type type));
40 | P(sym_calc_value,void,(struct symbol *sym));
41 | P(sym_get_type,enum symbol_type,(struct symbol *sym));
42 | P(sym_tristate_within_range,bool,(struct symbol *sym,tristate tri));
43 | P(sym_set_tristate_value,bool,(struct symbol *sym,tristate tri));
44 | P(sym_toggle_tristate_value,tristate,(struct symbol *sym));
45 | P(sym_string_valid,bool,(struct symbol *sym, const char *newval));
46 | P(sym_string_within_range,bool,(struct symbol *sym, const char *str));
47 | P(sym_set_string_value,bool,(struct symbol *sym, const char *newval));
48 | P(sym_is_changable,bool,(struct symbol *sym));
49 | P(sym_get_choice_prop,struct property *,(struct symbol *sym));
50 | P(sym_get_default_prop,struct property *,(struct symbol *sym));
51 | P(sym_get_string_value,const char *,(struct symbol *sym));
52 |
53 | P(prop_get_type_name,const char *,(enum prop_type type));
54 |
55 | /* expr.c */
56 | P(expr_compare_type,int,(enum expr_type t1, enum expr_type t2));
57 | P(expr_print,void,(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken));
58 |
--------------------------------------------------------------------------------
/kconfig/lpc17xx.cfg:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Platform Selection
8 | #
9 | # ARCH_LM3S is not set
10 | ARCH_LPC17XX=y
11 | # ARCH_STM32F4 is not set
12 | # ARCH_LPC1763 is not set
13 | # ARCH_LPC1764 is not set
14 | # ARCH_LPC1765 is not set
15 | # ARCH_LPC1766 is not set
16 | # ARCH_LPC1767 is not set
17 | ARCH_LPC1768=y
18 | # ARCH_LPC1769 is not set
19 | FLASH_SIZE_512KB=y
20 | RAM_SIZE_32KB=y
21 | CLK_100MHZ=y
22 | MACH_LPC1768MBED=y
23 | # MACH_SEEEDPRO is not set
24 |
25 | #
26 | # Kernel Configuration
27 | #
28 | KFLASHMEM_SIZE=48
29 | KRAMMEM_SIZE=6
30 |
31 | #
32 | # Subsystems
33 | #
34 |
35 | #
36 | # Filesystems
37 | #
38 | SYSFS=y
39 | MEMFS=y
40 | XIPFS=y
41 |
42 | #
43 | # Sockets
44 | #
45 | SOCK_UNIX=y
46 |
47 | #
48 | # Devices
49 | #
50 | DEVNULL=y
51 | # DEVUART is not set
52 | DEVGPIO=y
53 |
54 | #
55 | # Applications
56 | #
57 | FRESH=y
58 | # TASK2 is not set
59 | # PRODCONS is not set
60 |
--------------------------------------------------------------------------------
/kconfig/lxdialog/.gitignore:
--------------------------------------------------------------------------------
1 | #
2 | # Generated files
3 | #
4 | lxdialog
5 |
--------------------------------------------------------------------------------
/kconfig/lxdialog/BIG.FAT.WARNING:
--------------------------------------------------------------------------------
1 | This is NOT the official version of dialog. This version has been
2 | significantly modified from the original. It is for use by the Linux
3 | kernel configuration script. Please do not bother Savio Lam with
4 | questions about this program.
5 |
--------------------------------------------------------------------------------
/kconfig/lxdialog/check-lxdialog.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Check ncurses compatibility
3 |
4 | # What library to link
5 | ldflags()
6 | {
7 | pkg-config --libs ncursesw 2>/dev/null && exit
8 | pkg-config --libs ncurses 2>/dev/null && exit
9 | for ext in so a dll.a dylib ; do
10 | for lib in ncursesw ncurses curses ; do
11 | $cc -print-file-name=lib${lib}.${ext} | grep -q /
12 | if [ $? -eq 0 ]; then
13 | echo "-l${lib}"
14 | exit
15 | fi
16 | done
17 | done
18 | exit 1
19 | }
20 |
21 | # Where is ncurses.h?
22 | ccflags()
23 | {
24 | if pkg-config --cflags ncursesw 2>/dev/null; then
25 | echo '-DCURSES_LOC="" -DNCURSES_WIDECHAR=1'
26 | elif pkg-config --cflags ncurses 2>/dev/null; then
27 | echo '-DCURSES_LOC=""'
28 | elif [ -f /usr/include/ncursesw/curses.h ]; then
29 | echo '-I/usr/include/ncursesw -DCURSES_LOC=""'
30 | echo ' -DNCURSES_WIDECHAR=1'
31 | elif [ -f /usr/include/ncurses/ncurses.h ]; then
32 | echo '-I/usr/include/ncurses -DCURSES_LOC=""'
33 | elif [ -f /usr/include/ncurses/curses.h ]; then
34 | echo '-I/usr/include/ncurses -DCURSES_LOC=""'
35 | elif [ -f /usr/include/ncurses.h ]; then
36 | echo '-DCURSES_LOC=""'
37 | else
38 | echo '-DCURSES_LOC=""'
39 | fi
40 | }
41 |
42 | # Temp file, try to clean up after us
43 | tmp=.lxdialog.tmp
44 | trap "rm -f $tmp" 0 1 2 3 15
45 |
46 | # Check if we can link to ncurses
47 | check() {
48 | $cc -x c - -o $tmp 2>/dev/null <<'EOF'
49 | #include CURSES_LOC
50 | main() {}
51 | EOF
52 | if [ $? != 0 ]; then
53 | echo " *** Unable to find the ncurses libraries or the" 1>&2
54 | echo " *** required header files." 1>&2
55 | echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
56 | echo " *** " 1>&2
57 | echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
58 | echo " *** " 1>&2
59 | exit 1
60 | fi
61 | }
62 |
63 | usage() {
64 | printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
65 | }
66 |
67 | if [ $# -eq 0 ]; then
68 | usage
69 | exit 1
70 | fi
71 |
72 | cc=""
73 | case "$1" in
74 | "-check")
75 | shift
76 | cc="$@"
77 | check
78 | ;;
79 | "-ccflags")
80 | ccflags
81 | ;;
82 | "-ldflags")
83 | shift
84 | cc="$@"
85 | ldflags
86 | ;;
87 | "*")
88 | usage
89 | exit 1
90 | ;;
91 | esac
92 |
--------------------------------------------------------------------------------
/kconfig/lxdialog/yesno.c:
--------------------------------------------------------------------------------
1 | /*
2 | * yesno.c -- implements the yes/no box
3 | *
4 | * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
5 | * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
6 | *
7 | * This program is free software; you can redistribute it and/or
8 | * modify it under the terms of the GNU General Public License
9 | * as published by the Free Software Foundation; either version 2
10 | * of the License, or (at your option) any later version.
11 | *
12 | * This program is distributed in the hope that it will be useful,
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | * GNU General Public License for more details.
16 | *
17 | * You should have received a copy of the GNU General Public License
18 | * along with this program; if not, write to the Free Software
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 | */
21 |
22 | #include "dialog.h"
23 |
24 | /*
25 | * Display termination buttons
26 | */
27 | static void print_buttons(WINDOW * dialog, int height, int width, int selected)
28 | {
29 | int x = width / 2 - 10;
30 | int y = height - 2;
31 |
32 | print_button(dialog, gettext(" Yes "), y, x, selected == 0);
33 | print_button(dialog, gettext(" No "), y, x + 13, selected == 1);
34 |
35 | wmove(dialog, y, x + 1 + 13 * selected);
36 | wrefresh(dialog);
37 | }
38 |
39 | /*
40 | * Display a dialog box with two buttons - Yes and No
41 | */
42 | int dialog_yesno(const char *title, const char *prompt, int height, int width)
43 | {
44 | int i, x, y, key = 0, button = 0;
45 | WINDOW *dialog;
46 |
47 | do_resize:
48 | if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
49 | return -ERRDISPLAYTOOSMALL;
50 | if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
51 | return -ERRDISPLAYTOOSMALL;
52 |
53 | /* center dialog box on screen */
54 | x = (getmaxx(stdscr) - width) / 2;
55 | y = (getmaxy(stdscr) - height) / 2;
56 |
57 | draw_shadow(stdscr, y, x, height, width);
58 |
59 | dialog = newwin(height, width, y, x);
60 | keypad(dialog, TRUE);
61 |
62 | draw_box(dialog, 0, 0, height, width,
63 | dlg.dialog.atr, dlg.border.atr);
64 | wattrset(dialog, dlg.border.atr);
65 | mvwaddch(dialog, height - 3, 0, ACS_LTEE);
66 | for (i = 0; i < width - 2; i++)
67 | waddch(dialog, ACS_HLINE);
68 | wattrset(dialog, dlg.dialog.atr);
69 | waddch(dialog, ACS_RTEE);
70 |
71 | print_title(dialog, title, width);
72 |
73 | wattrset(dialog, dlg.dialog.atr);
74 | print_autowrap(dialog, prompt, width - 2, 1, 3);
75 |
76 | print_buttons(dialog, height, width, 0);
77 |
78 | while (key != KEY_ESC) {
79 | key = wgetch(dialog);
80 | switch (key) {
81 | case 'Y':
82 | case 'y':
83 | delwin(dialog);
84 | return 0;
85 | case 'N':
86 | case 'n':
87 | delwin(dialog);
88 | return 1;
89 |
90 | case TAB:
91 | case KEY_LEFT:
92 | case KEY_RIGHT:
93 | button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button);
94 |
95 | print_buttons(dialog, height, width, button);
96 | wrefresh(dialog);
97 | break;
98 | case ' ':
99 | case '\n':
100 | delwin(dialog);
101 | return button;
102 | case KEY_ESC:
103 | key = on_key_esc(dialog);
104 | break;
105 | case KEY_RESIZE:
106 | delwin(dialog);
107 | on_key_resize();
108 | goto do_resize;
109 | }
110 | }
111 |
112 | delwin(dialog);
113 | return key; /* ESC pressed */
114 | }
115 |
--------------------------------------------------------------------------------
/kconfig/merge_config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # merge_config.sh - Takes a list of config fragment values, and merges
3 | # them one by one. Provides warnings on overridden values, and specified
4 | # values that did not make it to the resulting .config file (due to missed
5 | # dependencies or config symbol removal).
6 | #
7 | # Portions reused from kconf_check and generate_cfg:
8 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/kconf_check
9 | # http://git.yoctoproject.org/cgit/cgit.cgi/yocto-kernel-tools/tree/tools/generate_cfg
10 | #
11 | # Copyright (c) 2009-2010 Wind River Systems, Inc.
12 | # Copyright 2011 Linaro
13 | #
14 | # This program is free software; you can redistribute it and/or modify
15 | # it under the terms of the GNU General Public License version 2 as
16 | # published by the Free Software Foundation.
17 | #
18 | # This program is distributed in the hope that it will be useful,
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 | # See the GNU General Public License for more details.
22 |
23 | clean_up() {
24 | rm -f $TMP_FILE
25 | exit
26 | }
27 | trap clean_up HUP INT TERM
28 |
29 | usage() {
30 | echo "Usage: $0 [OPTIONS] [CONFIG [...]]"
31 | echo " -h display this help text"
32 | echo " -m only merge the fragments, do not execute the make command"
33 | echo " -n use allnoconfig instead of alldefconfig"
34 | echo " -r list redundant entries when merging fragments"
35 | echo " -O dir to put generated output files"
36 | }
37 |
38 | MAKE=true
39 | ALLTARGET=alldefconfig
40 | WARNREDUN=false
41 | OUTPUT=.
42 |
43 | while true; do
44 | case $1 in
45 | "-n")
46 | ALLTARGET=allnoconfig
47 | shift
48 | continue
49 | ;;
50 | "-m")
51 | MAKE=false
52 | shift
53 | continue
54 | ;;
55 | "-h")
56 | usage
57 | exit
58 | ;;
59 | "-r")
60 | WARNREDUN=true
61 | shift
62 | continue
63 | ;;
64 | "-O")
65 | if [ -d $2 ];then
66 | OUTPUT=$(echo $2 | sed 's/\/*$//')
67 | else
68 | echo "output directory $2 does not exist" 1>&2
69 | exit 1
70 | fi
71 | shift 2
72 | continue
73 | ;;
74 | *)
75 | break
76 | ;;
77 | esac
78 | done
79 |
80 | INITFILE=$1
81 | shift;
82 |
83 | MERGE_LIST=$*
84 | SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p"
85 | TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX)
86 |
87 | echo "Using $INITFILE as base"
88 | cat $INITFILE > $TMP_FILE
89 |
90 | # Merge files, printing warnings on overrided values
91 | for MERGE_FILE in $MERGE_LIST ; do
92 | echo "Merging $MERGE_FILE"
93 | CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE)
94 |
95 | for CFG in $CFG_LIST ; do
96 | grep -q -w $CFG $TMP_FILE
97 | if [ $? -eq 0 ] ; then
98 | PREV_VAL=$(grep -w $CFG $TMP_FILE)
99 | NEW_VAL=$(grep -w $CFG $MERGE_FILE)
100 | if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then
101 | echo Value of $CFG is redefined by fragment $MERGE_FILE:
102 | echo Previous value: $PREV_VAL
103 | echo New value: $NEW_VAL
104 | echo
105 | elif [ "$WARNREDUN" = "true" ]; then
106 | echo Value of $CFG is redundant by fragment $MERGE_FILE:
107 | fi
108 | sed -i "/$CFG[ =]/d" $TMP_FILE
109 | fi
110 | done
111 | cat $MERGE_FILE >> $TMP_FILE
112 | done
113 |
114 | if [ "$MAKE" = "false" ]; then
115 | cp $TMP_FILE $OUTPUT/.config
116 | echo "#"
117 | echo "# merged configuration written to $OUTPUT/.config (needs make)"
118 | echo "#"
119 | clean_up
120 | exit
121 | fi
122 |
123 | # If we have an output dir, setup the O= argument, otherwise leave
124 | # it blank, since O=. will create an unnecessary ./source softlink
125 | OUTPUT_ARG=""
126 | if [ "$OUTPUT" != "." ] ; then
127 | OUTPUT_ARG="O=$OUTPUT"
128 | fi
129 |
130 |
131 | # Use the merged file as the starting point for:
132 | # alldefconfig: Fills in any missing symbols with Kconfig default
133 | # allnoconfig: Fills in any missing symbols with # CONFIG_* is not set
134 | make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET
135 |
136 |
137 | # Check all specified config values took (might have missed-dependency issues)
138 | for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do
139 |
140 | REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE)
141 | ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config)
142 | if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then
143 | echo "Value requested for $CFG not in final .config"
144 | echo "Requested value: $REQUESTED_VAL"
145 | echo "Actual value: $ACTUAL_VAL"
146 | echo ""
147 | fi
148 | done
149 |
150 | clean_up
151 |
--------------------------------------------------------------------------------
/kconfig/nconf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2008 Nir Tzachar
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include
24 | #include
25 | #include
26 |
27 | #include "ncurses.h"
28 |
29 | #define max(a, b) ({\
30 | typeof(a) _a = a;\
31 | typeof(b) _b = b;\
32 | _a > _b ? _a : _b; })
33 |
34 | #define min(a, b) ({\
35 | typeof(a) _a = a;\
36 | typeof(b) _b = b;\
37 | _a < _b ? _a : _b; })
38 |
39 | typedef enum {
40 | NORMAL = 1,
41 | MAIN_HEADING,
42 | MAIN_MENU_BOX,
43 | MAIN_MENU_FORE,
44 | MAIN_MENU_BACK,
45 | MAIN_MENU_GREY,
46 | MAIN_MENU_HEADING,
47 | SCROLLWIN_TEXT,
48 | SCROLLWIN_HEADING,
49 | SCROLLWIN_BOX,
50 | DIALOG_TEXT,
51 | DIALOG_MENU_FORE,
52 | DIALOG_MENU_BACK,
53 | DIALOG_BOX,
54 | INPUT_BOX,
55 | INPUT_HEADING,
56 | INPUT_TEXT,
57 | INPUT_FIELD,
58 | FUNCTION_TEXT,
59 | FUNCTION_HIGHLIGHT,
60 | ATTR_MAX
61 | } attributes_t;
62 | extern attributes_t attributes[];
63 |
64 | typedef enum {
65 | F_HELP = 1,
66 | F_SYMBOL = 2,
67 | F_INSTS = 3,
68 | F_CONF = 4,
69 | F_BACK = 5,
70 | F_SAVE = 6,
71 | F_LOAD = 7,
72 | F_SEARCH = 8,
73 | F_EXIT = 9,
74 | } function_key;
75 |
76 | void set_colors(void);
77 |
78 | /* this changes the windows attributes !!! */
79 | void print_in_middle(WINDOW *win,
80 | int starty,
81 | int startx,
82 | int width,
83 | const char *string,
84 | chtype color);
85 | int get_line_length(const char *line);
86 | int get_line_no(const char *text);
87 | const char *get_line(const char *text, int line_no);
88 | void fill_window(WINDOW *win, const char *text);
89 | int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
90 | int dialog_inputbox(WINDOW *main_window,
91 | const char *title, const char *prompt,
92 | const char *init, char **resultp, int *result_len);
93 | void refresh_all_windows(WINDOW *main_window);
94 | void show_scroll_win(WINDOW *main_window,
95 | const char *title,
96 | const char *text);
97 |
--------------------------------------------------------------------------------
/kconfig/qemu2.cfg:
--------------------------------------------------------------------------------
1 | #
2 | # Automatically generated file; DO NOT EDIT.
3 | # FROSTED Kernel Configuration
4 | #
5 |
6 | #
7 | # Platform Selection
8 | #
9 | ARCH_LM3S=y
10 | # ARCH_LPC17XX is not set
11 | # ARCH_STM32F4 is not set
12 | # ARCH_LPC1763 is not set
13 | # ARCH_LPC1764 is not set
14 | # ARCH_LPC1765 is not set
15 | # ARCH_LPC1766 is not set
16 | # ARCH_LPC1767 is not set
17 | # ARCH_LPC1768 is not set
18 | # ARCH_LPC1769 is not set
19 | ARCH_LM3S6965=y
20 | FLASH_SIZE_256KB=y
21 | RAM_SIZE_64KB=y
22 | # CLK_100MHZ is not set
23 | # MACH_LPC1768MBED is not set
24 | # MACH_SEEEDPRO is not set
25 | MACH_LM3S6965EVB=y
26 |
27 | #
28 | # Kernel Configuration
29 | #
30 | KFLASHMEM_SIZE=48
31 | KRAMMEM_SIZE=6
32 |
33 | #
34 | # Subsystems
35 | #
36 |
37 | #
38 | # Filesystems
39 | #
40 | SYSFS=y
41 | MEMFS=y
42 | XIPFS=y
43 |
44 | #
45 | # Sockets
46 | #
47 | SOCK_UNIX=y
48 |
49 | #
50 | # Devices
51 | #
52 | DEVNULL=y
53 | DEVUART=y
54 | USART_0=y
55 | # USART_1 is not set
56 | # USART_2 is not set
57 |
58 | #
59 | # Applications
60 | #
61 | FRESH=y
62 | # TASK2 is not set
63 | # PRODCONS is not set
64 |
--------------------------------------------------------------------------------
/kconfig/util.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2002-2005 Roman Zippel
3 | * Copyright (C) 2002-2005 Sam Ravnborg
4 | *
5 | * Released under the terms of the GNU GPL v2.0.
6 | */
7 |
8 | #include
9 | #include
10 | #include
11 | #include "lkc.h"
12 |
13 | /* file already present in list? If not add it */
14 | struct file *file_lookup(const char *name)
15 | {
16 | struct file *file;
17 | const char *file_name = sym_expand_string_value(name);
18 |
19 | for (file = file_list; file; file = file->next) {
20 | if (!strcmp(name, file->name)) {
21 | free((void *)file_name);
22 | return file;
23 | }
24 | }
25 |
26 | file = xmalloc(sizeof(*file));
27 | memset(file, 0, sizeof(*file));
28 | file->name = file_name;
29 | file->next = file_list;
30 | file_list = file;
31 | return file;
32 | }
33 |
34 | /* write a dependency file as used by kbuild to track dependencies */
35 | int file_write_dep(const char *name)
36 | {
37 | struct symbol *sym, *env_sym;
38 | struct expr *e;
39 | struct file *file;
40 | FILE *out;
41 |
42 | if (!name)
43 | name = ".kconfig.d";
44 | out = fopen("..config.tmp", "w");
45 | if (!out)
46 | return 1;
47 | fprintf(out, "deps_config := \\\n");
48 | for (file = file_list; file; file = file->next) {
49 | if (file->next)
50 | fprintf(out, "\t%s \\\n", file->name);
51 | else
52 | fprintf(out, "\t%s\n", file->name);
53 | }
54 | fprintf(out, "\n%s: \\\n"
55 | "\t$(deps_config)\n\n", conf_get_autoconfig_name());
56 |
57 | expr_list_for_each_sym(sym_env_list, e, sym) {
58 | struct property *prop;
59 | const char *value;
60 |
61 | prop = sym_get_env_prop(sym);
62 | env_sym = prop_get_symbol(prop);
63 | if (!env_sym)
64 | continue;
65 | value = getenv(env_sym->name);
66 | if (!value)
67 | value = "";
68 | fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
69 | fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name());
70 | fprintf(out, "endif\n");
71 | }
72 |
73 | fprintf(out, "\n$(deps_config): ;\n");
74 | fclose(out);
75 | rename("..config.tmp", name);
76 | return 0;
77 | }
78 |
79 |
80 | /* Allocate initial growable string */
81 | struct gstr str_new(void)
82 | {
83 | struct gstr gs;
84 | gs.s = xmalloc(sizeof(char) * 64);
85 | gs.len = 64;
86 | gs.max_width = 0;
87 | strcpy(gs.s, "\0");
88 | return gs;
89 | }
90 |
91 | /* Allocate and assign growable string */
92 | struct gstr str_assign(const char *s)
93 | {
94 | struct gstr gs;
95 | gs.s = strdup(s);
96 | gs.len = strlen(s) + 1;
97 | gs.max_width = 0;
98 | return gs;
99 | }
100 |
101 | /* Free storage for growable string */
102 | void str_free(struct gstr *gs)
103 | {
104 | if (gs->s)
105 | free(gs->s);
106 | gs->s = NULL;
107 | gs->len = 0;
108 | }
109 |
110 | /* Append to growable string */
111 | void str_append(struct gstr *gs, const char *s)
112 | {
113 | size_t l;
114 | if (s) {
115 | l = strlen(gs->s) + strlen(s) + 1;
116 | if (l > gs->len) {
117 | gs->s = realloc(gs->s, l);
118 | gs->len = l;
119 | }
120 | strcat(gs->s, s);
121 | }
122 | }
123 |
124 | /* Append printf formatted string to growable string */
125 | void str_printf(struct gstr *gs, const char *fmt, ...)
126 | {
127 | va_list ap;
128 | char s[10000]; /* big enough... */
129 | va_start(ap, fmt);
130 | vsnprintf(s, sizeof(s), fmt, ap);
131 | str_append(gs, s);
132 | va_end(ap);
133 | }
134 |
135 | /* Retrieve value of growable string */
136 | const char *str_get(struct gstr *gs)
137 | {
138 | return gs->s;
139 | }
140 |
141 | void *xmalloc(size_t size)
142 | {
143 | void *p = malloc(size);
144 | if (p)
145 | return p;
146 | fprintf(stderr, "Out of memory.\n");
147 | exit(1);
148 | }
149 |
150 | void *xcalloc(size_t nmemb, size_t size)
151 | {
152 | void *p = calloc(nmemb, size);
153 | if (p)
154 | return p;
155 | fprintf(stderr, "Out of memory.\n");
156 | exit(1);
157 | }
158 |
159 |
160 |
--------------------------------------------------------------------------------
/kconfig/zconf.gperf:
--------------------------------------------------------------------------------
1 | %language=ANSI-C
2 | %define hash-function-name kconf_id_hash
3 | %define lookup-function-name kconf_id_lookup
4 | %define string-pool-name kconf_id_strings
5 | %compare-strncmp
6 | %enum
7 | %pic
8 | %struct-type
9 |
10 | struct kconf_id;
11 |
12 | static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
13 |
14 | %%
15 | mainmenu, T_MAINMENU, TF_COMMAND
16 | menu, T_MENU, TF_COMMAND
17 | endmenu, T_ENDMENU, TF_COMMAND
18 | source, T_SOURCE, TF_COMMAND
19 | choice, T_CHOICE, TF_COMMAND
20 | endchoice, T_ENDCHOICE, TF_COMMAND
21 | comment, T_COMMENT, TF_COMMAND
22 | config, T_CONFIG, TF_COMMAND
23 | menuconfig, T_MENUCONFIG, TF_COMMAND
24 | help, T_HELP, TF_COMMAND
25 | if, T_IF, TF_COMMAND|TF_PARAM
26 | endif, T_ENDIF, TF_COMMAND
27 | depends, T_DEPENDS, TF_COMMAND
28 | optional, T_OPTIONAL, TF_COMMAND
29 | default, T_DEFAULT, TF_COMMAND, S_UNKNOWN
30 | prompt, T_PROMPT, TF_COMMAND
31 | tristate, T_TYPE, TF_COMMAND, S_TRISTATE
32 | def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE
33 | bool, T_TYPE, TF_COMMAND, S_BOOLEAN
34 | boolean, T_TYPE, TF_COMMAND, S_BOOLEAN
35 | def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN
36 | int, T_TYPE, TF_COMMAND, S_INT
37 | hex, T_TYPE, TF_COMMAND, S_HEX
38 | string, T_TYPE, TF_COMMAND, S_STRING
39 | select, T_SELECT, TF_COMMAND
40 | range, T_RANGE, TF_COMMAND
41 | visible, T_VISIBLE, TF_COMMAND
42 | option, T_OPTION, TF_COMMAND
43 | on, T_ON, TF_PARAM
44 | modules, T_OPT_MODULES, TF_OPTION
45 | defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION
46 | env, T_OPT_ENV, TF_OPTION
47 | allnoconfig_y, T_OPT_ALLNOCONFIG_Y,TF_OPTION
48 | %%
49 |
--------------------------------------------------------------------------------
/kernel/adc.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_ADC
2 | #define INC_ADC
3 |
4 | #define NUM_ADC_CHANNELS 16
5 |
6 | struct adc_config {
7 | uint32_t base;
8 | uint32_t irq;
9 | uint32_t rcc;
10 | const char * name;
11 | uint8_t channel_array[NUM_ADC_CHANNELS];
12 | uint8_t num_channels;
13 |
14 | struct dma_config dma;
15 | uint32_t dma_rcc;
16 | };
17 |
18 | void adc_init(const struct adc_config adc_configs[], int num_adc);
19 |
20 | #endif
21 |
22 |
--------------------------------------------------------------------------------
/kernel/bflt.h:
--------------------------------------------------------------------------------
1 | /*
2 | */
3 |
4 | #include
5 | #include "flat.h"
6 |
7 | #ifndef _BFLT_H_
8 | #define _BFLT_H_
9 |
10 | int bflt_load(uint8_t* from, void **reloc_text, void **reloc_data, void **reloc_bss,
11 | void **entry_point, size_t *stack_size, uint32_t *got_loc, uint32_t *text_len, uint32_t *data_len);
12 |
13 | #endif
14 |
--------------------------------------------------------------------------------
/kernel/cdc_acm.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_CDC_ACM_H
2 | #define INC_CDC_ACM_H
3 |
4 |
5 | struct cdcacm_addr {
6 | const char * name;
7 | const char * usb_name;
8 | };
9 |
10 | void cdcacm_init(struct fnode *dev, const struct cdcacm_addr cdcacm_addrs[], int num_cdcacm);
11 |
12 |
13 | #endif
14 |
15 |
--------------------------------------------------------------------------------
/kernel/cdc_ecm.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_CDC_ECM_H
2 | #define INC_CDC_ECM_H
3 |
4 | #define USBETH_MAX_FRAME 1514
5 |
6 |
7 |
8 | void cdcecm_init_init(const unsigned char * usb_name);
9 |
10 |
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/kernel/cirbuf.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera, Maxime Vincent
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "cirbuf.h"
23 | #include "errno.h"
24 |
25 | struct cirbuf {
26 | uint8_t *buf;
27 | uint8_t *readptr;
28 | uint8_t *writeptr;
29 | int bufsize;
30 | };
31 |
32 | struct cirbuf * cirbuf_create(int size)
33 | {
34 | struct cirbuf* inbuf;
35 | if (size <= 0)
36 | return NULL;
37 |
38 | inbuf = kalloc(sizeof(struct cirbuf));
39 | if (!inbuf)
40 | return NULL;
41 |
42 | inbuf->buf = kalloc(size);
43 | if (!inbuf->buf)
44 | {
45 | kfree(inbuf);
46 | return NULL;
47 | }
48 |
49 | inbuf->bufsize = size;
50 | inbuf->readptr = inbuf->buf;
51 | inbuf->writeptr = inbuf->buf;
52 | return inbuf;
53 | }
54 |
55 | /* 0 on success, -1 on fail */
56 | int cirbuf_writebyte(struct cirbuf *cb, uint8_t byte)
57 | {
58 | if (!cb)
59 | return -1;
60 |
61 | /* check if there is space */
62 | if (!cirbuf_bytesfree(cb))
63 | return -1;
64 |
65 | *cb->writeptr = byte;
66 | cb->writeptr++;
67 |
68 | /* wrap if needed */
69 | if (cb->writeptr > (cb->buf + cb->bufsize - 1u))
70 | cb->writeptr = cb->buf;
71 |
72 | return 0;
73 | }
74 |
75 | /* 0 on success, -1 on fail */
76 | int cirbuf_readbyte(struct cirbuf *cb, uint8_t *byte)
77 | {
78 | if (!cb || !byte)
79 | return -1;
80 |
81 | /* check if there is data */
82 | if (!cirbuf_bytesinuse(cb))
83 | return -1;
84 |
85 | *byte = *cb->readptr++;
86 |
87 | /* wrap if needed */
88 | if (cb->readptr > (cb->buf + cb->bufsize - 1u))
89 | cb->readptr = cb->buf;
90 |
91 | return 0;
92 | }
93 |
94 | int cirbuf_readbytes(struct cirbuf *cb, void *bytes, int len)
95 | {
96 | int buflen;
97 | int i;
98 | char *dst = bytes;
99 | if (!cb || !bytes)
100 | return -1;
101 |
102 | /* check if there is data */
103 | buflen = cirbuf_bytesinuse(cb);
104 | if (buflen == 0)
105 | return -1;
106 | if (len > buflen)
107 | len = buflen;
108 |
109 | for (i = 0; i < len; i++) {
110 | dst[i] = *(cb->readptr++);
111 | /* wrap if needed */
112 | if (cb->readptr > (cb->buf + cb->bufsize - 1u))
113 | cb->readptr = cb->buf;
114 | }
115 | return len;
116 | }
117 |
118 | /* written len on success, 0 on fail */
119 | int cirbuf_writebytes(struct cirbuf *cb, const uint8_t * bytes, int len)
120 | {
121 | uint8_t byte;
122 | int freesize;
123 | int tot_len = len;
124 | if (!cb)
125 | return 0;
126 |
127 | /* check if there is space */
128 | freesize = cirbuf_bytesfree(cb);
129 | if (!freesize)
130 | return 0;
131 | if (freesize < len) {
132 | len = freesize;
133 | tot_len = freesize;
134 | }
135 |
136 | /* Wrap needed ? */
137 | if ((cb->writeptr + len) > (cb->buf + cb->bufsize) - 1u)
138 | {
139 | int len_first_part = cb->buf + cb->bufsize - cb->writeptr; /* end - current position */
140 | memcpy(cb->writeptr, bytes, len_first_part);
141 | bytes += len_first_part;
142 | cb->writeptr = cb->buf; /* set to start of buffer */
143 | len -= len_first_part;
144 | }
145 | /* write remaining part */
146 | if (len)
147 | {
148 | memcpy(cb->writeptr, bytes, len);
149 | cb->writeptr += len;
150 | }
151 |
152 | return tot_len;
153 | }
154 |
155 | int cirbuf_bytesfree(struct cirbuf *cb)
156 | {
157 | int bytes;
158 | if (!cb)
159 | return -1;
160 |
161 | bytes = (int)(cb->readptr - cb->writeptr - 1);
162 | if (cb->writeptr >= cb->readptr)
163 | bytes += cb->bufsize;
164 |
165 | return bytes;
166 | }
167 |
168 | int cirbuf_bytesinuse(struct cirbuf *cb)
169 | {
170 | int bytes;
171 | if (!cb)
172 | return -1;
173 |
174 | bytes = (int)(cb->writeptr - cb->readptr);
175 | if (cb->writeptr < cb->readptr)
176 | bytes += cb->bufsize;
177 |
178 | return (bytes);
179 | }
180 |
181 |
--------------------------------------------------------------------------------
/kernel/cirbuf.h:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 |
3 | #ifndef CIR_BUF_H
4 | #define CIR_BUF_H
5 |
6 | struct cirbuf;
7 |
8 | struct cirbuf * cirbuf_create(int size);
9 | /* 0 on success, -1 on fail */
10 | int cirbuf_writebyte(struct cirbuf *cb, uint8_t byte);
11 | /* 0 on success, -1 on fail */
12 | int cirbuf_readbyte(struct cirbuf *cb, uint8_t *byte);
13 | /* len on success, -1 on fail */
14 | int cirbuf_writebytes(struct cirbuf *cb, const uint8_t * bytes, int len);
15 |
16 | /* len on success, -1 on fail */
17 | int cirbuf_readbytes(struct cirbuf *cb, void *bytes, int len);
18 | int cirbuf_bytesfree(struct cirbuf *cb);
19 | int cirbuf_bytesinuse(struct cirbuf *cb);
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/kernel/crypto/aes.h:
--------------------------------------------------------------------------------
1 | #ifndef CRYPTO_AES_H_
2 | #define CRYPTO_AES_H_
3 |
4 | #include "crypto/misc.h"
5 |
6 | enum {
7 | AES_ENC_TYPE = 1, /* cipher unique type */
8 | AES_ENCRYPTION = 0,
9 | AES_DECRYPTION = 1,
10 | AES_BLOCK_SIZE = 16
11 | };
12 |
13 | typedef struct Aes {
14 | /* AESNI needs key first, rounds 2nd, not sure why yet */
15 | __attribute__ ( (aligned (16))) word32 key[60];
16 | word32 rounds;
17 |
18 | __attribute__ ( (aligned (16))) word32 reg[AES_BLOCK_SIZE / sizeof(word32)]; /* for CBC mode */
19 | __attribute__ ( (aligned (16))) word32 tmp[AES_BLOCK_SIZE / sizeof(word32)]; /* same */
20 |
21 | void *heap; /* memory hint to use */
22 | } Aes;
23 |
24 |
25 | int wc_AesSetKey(Aes *aes, const byte *userKey, word32 keylen, const byte *iv,
26 | int dir);
27 | int wc_AesCbcEncrypt(Aes *aes, byte *out, const byte *in, word32 sz);
28 | int wc_AesCbcDecrypt(Aes *aes, byte *out, const byte *in, word32 sz);
29 |
30 | #endif /* CRYPTO_AES_H_ */
31 |
--------------------------------------------------------------------------------
/kernel/crypto/misc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Copyright (C) 2006-2016 wolfSSL Inc.
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "crypto/misc.h"
23 |
24 |
25 | word32 rotlFixed(word32 x, word32 y)
26 | {
27 | return (x << y) | (x >> (sizeof(y) * 8 - y));
28 | }
29 |
30 | word32 rotrFixed(word32 x, word32 y)
31 | {
32 | return (x >> y) | (x << (sizeof(y) * 8 - y));
33 | }
34 |
35 | word32 ByteReverseWord32(word32 value)
36 | {
37 | /* 6 instructions with rotate instruction, 8 without */
38 | value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);
39 | return rotlFixed(value, 16U);
40 | }
41 |
42 | void ByteReverseWords(word32 *out, const word32 *in, word32 byte_count)
43 | {
44 | word32 count = byte_count/(word32)sizeof(word32), i;
45 |
46 | for (i = 0; i < count; i++)
47 | out[i] = ByteReverseWord32(in[i]);
48 | }
49 |
50 | static void XorWords(word32 *r, const word32 *a, word32 n)
51 | {
52 | word32 i;
53 |
54 | for (i = 0; i < n; i++) r[i] ^= a[i];
55 | }
56 |
57 | void xorbuf(void *buf, const void *mask, word32 count)
58 | {
59 | if ((((word32)buf | (word32)mask | count) % sizeof(word32)) == 0)
60 | XorWords((word32 *)buf, (const word32 *)mask, (count / sizeof(word32)));
61 | else {
62 | word32 i;
63 | byte *b = (byte *)buf;
64 | const byte *m = (const byte *)mask;
65 |
66 | for (i = 0; i < count; i++) b[i] ^= m[i];
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/kernel/crypto/misc.h:
--------------------------------------------------------------------------------
1 | #ifndef CRYPTO_MISC_H_
2 | #define CRYPTO_MISC_H_
3 |
4 | #define XMEMCPY(d,s,l) memcpy((d),(s),(l))
5 | #define XMEMSET(b,c,l) memset((b),(c),(l))
6 | #define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
7 | #define XMEMMOVE(d,s,l) memmove((d),(s),(l))
8 |
9 | #ifndef byte
10 | typedef unsigned char byte;
11 | #endif
12 |
13 | typedef unsigned short word16;
14 | typedef unsigned int word32;
15 |
16 | word32 rotlFixed(word32 x, word32 y);
17 | word32 rotrFixed(word32 x, word32 y);
18 | word32 ByteReverseWord32(word32 value);
19 | void ByteReverseWords(word32 *out, const word32 *in, word32 byte_count);
20 | void xorbuf(void *buf, const void *mask, word32 count);
21 |
22 | #endif /* CRYPTO_MISC_H_ */
23 |
--------------------------------------------------------------------------------
/kernel/crypto/sha256.h:
--------------------------------------------------------------------------------
1 | #ifndef CRYPTO_SHA256_H_
2 | #define CRYPTO_SHA256_H_
3 |
4 | #include "crypto/misc.h"
5 |
6 | /* in bytes */
7 | enum {
8 | SHA256 = 2, /* hash type unique */
9 | SHA256_BLOCK_SIZE = 64,
10 | SHA256_DIGEST_SIZE = 32,
11 | SHA256_PAD_SIZE = 56
12 | };
13 |
14 | /* Sha256 digest */
15 | typedef struct Sha256 {
16 | word32 buffLen; /* in bytes */
17 | word32 loLen; /* length in bytes */
18 | word32 hiLen; /* length in bytes */
19 | word32 digest[SHA256_DIGEST_SIZE / sizeof(word32)];
20 | word32 buffer[SHA256_BLOCK_SIZE / sizeof(word32)];
21 | } Sha256;
22 |
23 | int wc_InitSha256(Sha256 *sha256);
24 | int wc_Sha256Update(Sha256 *sha256, const byte *data, word32 len);
25 | int wc_Sha256Final(Sha256 *sha256, byte *hash);
26 |
27 | #endif /* CRYPTO_SHA256_H_ */
28 |
--------------------------------------------------------------------------------
/kernel/device.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_DEVICE
2 | #define INC_DEVICE
3 |
4 | #include "frosted.h"
5 |
6 | struct device {
7 | struct fnode *fno;
8 | mutex_t * mutex;
9 | struct task *task;
10 | };
11 |
12 | int device_open(const char *path, int flags);
13 | struct device * device_fno_init(struct module * mod, const char * name, struct fnode *node, uint32_t flags,void * priv);
14 |
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/kernel/drivers/device.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors:
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 |
24 | int device_open(const char *path, int flags)
25 | {
26 | struct fnode *f = fno_search(path);
27 | if (!f)
28 | return -1;
29 | return task_filedesc_add(f);
30 | }
31 |
32 | struct device * device_fno_init(struct module * mod, const char * name, struct fnode *node, uint32_t flags, void * priv)
33 | {
34 | struct device * device = kalloc(sizeof(struct device));
35 | device->fno = NULL;
36 | /* Only create a device node if there is a name */
37 | if(name)
38 | {
39 | device->fno = fno_create(mod, name, node);
40 | device->fno->priv = priv;
41 | device->fno->flags |= flags;
42 | }
43 | device->task = NULL;
44 | device->mutex = mutex_init();
45 | return device;
46 | }
47 |
--------------------------------------------------------------------------------
/kernel/drivers/dma.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_DMA
2 | #define INC_DMA
3 |
4 | struct dma_config {
5 | uint32_t base;
6 | uint8_t stream;
7 | uint32_t channel;
8 | uint32_t psize;
9 | uint32_t msize;
10 | uint32_t dirn;
11 | uint32_t prio;
12 | uint32_t paddr;
13 | uint32_t irq;
14 | };
15 |
16 | void init_dma(const struct dma_config * dma, uint32_t ptr, uint32_t len);
17 |
18 | #endif
19 |
20 |
--------------------------------------------------------------------------------
/kernel/drivers/dsp.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_DSP
2 | #define INC_DSP
3 |
4 | #ifdef CONFIG_DSP
5 | int dsp_init(void);
6 | #else
7 | # define dsp_init() ((-ENOENT))
8 | #endif
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/kernel/drivers/eth.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_ETH
2 | #define INC_ETH
3 | #include "frosted.h"
4 | #include "gpio.h"
5 |
6 | struct eth_config {
7 | const struct gpio_config *pio_mii;
8 | const unsigned int n_pio_mii;
9 | const struct gpio_config pio_phy_reset;
10 | const int has_phy_reset;
11 | };
12 |
13 | #ifdef CONFIG_DEVETH
14 | int ethernet_init(const struct eth_config *conf);
15 | int pico_eth_start(void);
16 | #else
17 | # define ethernet_init(x) ((-ENOENT))
18 | # define pico_eth_start() ((-ENOENT))
19 | #endif
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/kernel/drivers/exti.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_STM32F4EXTI
2 | #define INC_STM32F4EXTI
3 | #include
4 | #include
5 |
6 | int exti_register(uint32_t base, uint16_t pin, uint8_t trigger, void (*isr)(void *), void *isr_arg);
7 | void exti_unregister(int pin);
8 | int exti_enable(int idx, int enable);
9 | void exti_init(void);
10 |
11 | #endif
12 |
--------------------------------------------------------------------------------
/kernel/drivers/fbcon.h:
--------------------------------------------------------------------------------
1 | #ifndef FBCON_INCLUDED
2 | #define FBCON_INCLUDED
3 |
4 | #include
5 | #include "frosted.h"
6 |
7 | #ifdef CONFIG_DEVFBCON
8 | /* kernel init */
9 | int fbcon_init(uint32_t cols, uint32_t rows);
10 | #else
11 | # define fbcon_init(...) ((-ENOENT))
12 | #endif
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/kernel/drivers/fonts.h:
--------------------------------------------------------------------------------
1 | #ifndef INCLUDE_FONT_DEFINITION
2 | #define INCLUDE_FONT_DEFINITION
3 |
4 | #ifdef CONFIG_FONT_7x6
5 | # define FONT_HEIGHT 7
6 | # define FONT_WIDTH 6
7 | #endif
8 |
9 | #ifdef CONFIG_FONT_8x8
10 | # define FONT_HEIGHT 8
11 | # define FONT_WIDTH 8
12 | #endif
13 |
14 | extern const unsigned char fb_font[256][FONT_HEIGHT];
15 |
16 | #endif
17 |
--------------------------------------------------------------------------------
/kernel/drivers/framebuffer.h:
--------------------------------------------------------------------------------
1 | #ifndef FRAMEBUFFER_INCLUDED
2 | #define FRAMEBUFFER_INCLUDED
3 |
4 | #include
5 | #include "frosted.h"
6 | #include
7 |
8 | struct fb_ops;
9 |
10 |
11 | struct fb_info {
12 | struct fb_var_screeninfo var; /* Current var */
13 | //struct fb_fix_screeninfo fix; /* Current fix */
14 | struct fb_videomode *mode; /* current mode */
15 | //struct backlight_device *bl_dev;
16 |
17 | struct fb_ops *fbops;
18 | struct device *dev; /* This is this fb device */
19 | uint8_t *screen_buffer; /* Framebuffer address */
20 | };
21 |
22 | struct fb_ops {
23 | /* open/release and usage marking */
24 | int (*fb_open)(struct fb_info *info);
25 | int (*fb_release)(struct fb_info *info);
26 |
27 | /* checks var and eventually tweaks it to something supported,
28 | * DO NOT MODIFY PAR */
29 | int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info);
30 |
31 | /* set the video mode according to info->var */
32 | int (*fb_set_par)(struct fb_info *info);
33 |
34 | /* set color registers in batch */
35 | int (*fb_setcmap)(uint32_t *cmap, struct fb_info *info);
36 |
37 | /* blank display */
38 | int (*fb_blank)(struct fb_info *info);
39 |
40 | /* Draws a rectangle */
41 | //void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect);
42 | /* Copy data from area to another */
43 | //void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region);
44 | /* Draws a image to the display */
45 | //void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image);
46 |
47 | /* Draws cursor */
48 | //int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor);
49 |
50 | /* Rotates the display */
51 | //void (*fb_rotate)(struct fb_info *info, int angle);
52 |
53 | /* perform fb specific ioctl (optional) */
54 | int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, unsigned long arg);
55 |
56 | /* teardown any resources to do with this framebuffer */
57 | void (*fb_destroy)(struct fb_info *info);
58 | };
59 |
60 |
61 | #ifdef CONFIG_DEVFRAMEBUFFER
62 | /* low-level drivers must call this register function first */
63 | int register_framebuffer(struct fb_info *fb_info);
64 |
65 | /* Higher level drivers may access fb screen directly */
66 | unsigned char *framebuffer_get(void);
67 | int framebuffer_setcmap(uint32_t *cmap);
68 |
69 | /* kernel init */
70 | int fb_init(void);
71 | #else
72 | # define register_framebuffer(...) ((-ENOENT))
73 | # define fb_init() ((-ENOENT))
74 | #endif
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/kernel/drivers/frand.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: brabo
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 | #include "frand.h"
24 | #include "fortuna.h"
25 | #include "rng.h"
26 | #include
27 | #include
28 |
29 | #if defined(STM32F2) || defined(STM32F4) || defined(STM32F7)
30 | # include "unicore-mx/stm32/rng.h"
31 | #endif
32 |
33 | #define MAX_FRANDS (1)
34 |
35 | extern uint32_t req;
36 |
37 | static struct frand_info *frand[MAX_FRANDS] = { 0 };
38 |
39 | static int frand_open(const char *path, int flags);
40 | static int frand_read(struct fnode *fno, void *buf, unsigned int len);
41 |
42 | static struct module mod_devfrand = {
43 | .family = FAMILY_FILE,
44 | .name = "frand",
45 | .ops.open = frand_open,
46 | .ops.read = frand_read,
47 | };
48 |
49 | static int frand_open(const char *path, int flags)
50 | {
51 | struct fnode *f = fno_search(path);
52 |
53 | if (!f)
54 | return -1;
55 |
56 | return device_open(path, flags);
57 | }
58 |
59 | static int frand_read(struct fnode *fno, void *buf, unsigned int len)
60 | {
61 | struct frand_info *frand;
62 |
63 | if (len == 0)
64 | return len;
65 |
66 | frand = (struct frand_info *)FNO_MOD_PRIV(fno, &mod_devfrand);
67 | if (!frand)
68 | return -1;
69 |
70 | // mutex_lock(fb->dev->mutex);
71 |
72 | fortuna_get_bytes(buf, len);
73 | req += len;
74 | rng_enable_interrupt();
75 |
76 | //mutex_unlock(fb->dev->mutex);
77 | return len;
78 | }
79 |
80 |
81 | static int frand_fno_init(struct fnode *dev, struct frand_info *frand)
82 | {
83 | static int num_frand = 0;
84 | char name[7] = "frand";
85 |
86 | if (!frand)
87 | return -1;
88 |
89 | name[6] = '0' + num_frand++;
90 |
91 | frand->dev = device_fno_init(&mod_devfrand, name, dev, FL_TTY, frand);
92 |
93 | return 0;
94 | }
95 |
96 | void frand_init(struct fnode *dev)
97 | {
98 | /* Ony one FRAND supported for now */
99 | frand_fno_init(dev, frand[0]);
100 | }
101 |
102 | /* Register a low-level frand driver */
103 | int register_frand(struct frand_info *frand_info)
104 | {
105 | if (!frand_info)
106 | return -1;
107 |
108 | if (!frand_info->frandops)
109 | return -1;
110 |
111 | if (frand_info->frandops->frand_open)
112 | frand_info->frandops->frand_open(frand_info);
113 |
114 | frand[0] = frand_info;
115 |
116 | register_module(&mod_devfrand);
117 | fortuna_init();
118 |
119 | return 0;
120 | }
121 |
122 |
--------------------------------------------------------------------------------
/kernel/drivers/ft5336.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 | #include
24 | #include "cirbuf.h"
25 | #include "dma.h"
26 | #include "cirbuf.h"
27 | #include "i2c.h"
28 |
29 | #define FT5336_I2C_ADDR (0x70)
30 | #define MAX_W (480)
31 | #define MAX_H (272)
32 |
33 | #define FT5336_MODE (0x00)
34 | #define FT5336_GESTURE_ID (0x01)
35 | #define FT5336_TOUCHDATA (0x02)
36 | # define TD_PRESS (0x00)
37 | # define TD_RELEASE (0x01)
38 | # define TD_CONTACT (0x02)
39 | #define FT5336_P1_XH (0x03)
40 | #define FT5336_P1_YH (0x05)
41 |
42 | #define FT5336_G_MODE (0xA4)
43 | #define FT5336_G_MODE_INTERRUPT (0x01)
44 |
45 | #define FT5336_CHIP_ID (0xA8)
46 | #define FT5336_CHIP_ID_VAL (0x51)
47 |
48 | /* Single device supported in this driver. */
49 | #define ST_OFF 0
50 | #define ST_RDY 1
51 | #define ST_ON 2
52 |
53 |
54 | struct dev_ts {
55 | struct i2c_slave i2c;
56 | struct device *dev;
57 | uint8_t i2c_data;
58 | int state;
59 | } Ts;
60 |
61 |
62 |
63 | /* Module description */
64 | int ft5336_read(struct fnode *fno, void *buf, unsigned int len)
65 | {
66 | return 0;
67 | }
68 |
69 | static struct module mod_devts = {
70 | .family = FAMILY_FILE,
71 | .name = "ts",
72 | .ops.open = device_open,
73 | .ops.read = ft5336_read
74 | };
75 |
76 |
77 | static void ft5336_task(void *arg)
78 | {
79 | (void)arg;
80 | uint8_t val;
81 |
82 | if (i2c_kthread_read(&Ts.i2c, FT5336_CHIP_ID, &val, 1) > 0) {
83 | if (val != FT5336_CHIP_ID_VAL)
84 | return 0; /* kthread terminated. */
85 | }
86 |
87 | val = FT5336_G_MODE_INTERRUPT;
88 | i2c_kthread_write(&Ts.i2c, FT5336_G_MODE, &val, 1);
89 | }
90 |
91 | int ft5336_init(uint32_t bus)
92 | {
93 | int i;
94 | struct fnode *devdir = fno_search("/dev");
95 | if (!devdir)
96 | return -ENOENT;
97 | memset(&Ts, 0, sizeof(struct dev_ts));
98 | Ts.dev = device_fno_init(&mod_devts, "ts", devdir, 0, &Ts);
99 |
100 | /* Populate i2c_slave struct */
101 | Ts.i2c.bus = bus;
102 | Ts.i2c.address = FT5336_I2C_ADDR;
103 | kthread_create(ft5336_task, NULL);
104 | return 0;
105 | }
106 |
--------------------------------------------------------------------------------
/kernel/drivers/gpio.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_GPIO
2 | #define INC_GPIO
3 | #include "frosted.h"
4 | #include "sys/frosted-io.h"
5 |
6 |
7 |
8 | #if defined(STM32F4) || defined(STM32F7)
9 | #include
10 | #endif
11 |
12 |
13 | struct gpio_config {
14 | uint32_t base;
15 | uint32_t pin;
16 | uint32_t mode;
17 | uint8_t pullupdown;
18 | uint8_t speed;
19 | uint8_t optype;
20 | uint8_t af;
21 | uint32_t trigger;
22 | const char* name;
23 | };
24 |
25 | #define GPIO_FL_PROTECTED (0x10)
26 | #define SET_TRIGGER_WAITING(x,t) x->flags|=t
27 | #define RESET_TRIGGER_WAITING(x) x->flags&=0xFFFFFFF0
28 | #define TRIGGER_WAITING(x) (((x->flags & 0x0F) == GPIO_TRIGGER_RAISE)?1:0)
29 |
30 | #define IS_PROTECTED(x) ((x->flags & GPIO_FL_PROTECTED) == GPIO_FL_PROTECTED)
31 |
32 | struct dev_gpio {
33 | struct device *dev;
34 | struct module *owner; /* Module that registered the gpio */
35 | uint32_t mode;
36 | uint32_t af;
37 | uint32_t base;
38 | uint32_t pin;
39 | uint8_t trigger;
40 | int exti_idx;
41 | unsigned int flags;
42 | uint32_t optype;
43 | uint32_t speed;
44 | uint8_t pullupdown;
45 | struct dev_gpio *next;
46 | };
47 |
48 | extern struct dev_gpio *Gpio_list;
49 |
50 | int gpio_init(void);
51 | int gpio_list_len(void);
52 | int gpio_create(struct module *mod, const struct gpio_config *gpio_config);
53 | #endif
54 |
--------------------------------------------------------------------------------
/kernel/drivers/i2c.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_I2C
2 | #define INC_I2C
3 | #include "dma.h"
4 | #include "gpio.h"
5 |
6 |
7 | struct i2c_config {
8 | int idx;
9 | uint32_t base;
10 | uint32_t ev_irq;
11 | uint32_t er_irq;
12 | uint32_t rcc;
13 | uint32_t clock_speed;
14 | uint32_t fast_mode;
15 | uint32_t rise_time;
16 | uint32_t bus_clk_frequency;
17 | uint32_t clock_f;
18 | uint32_t dma_rcc;
19 | struct dma_config tx_dma;
20 | struct dma_config rx_dma;
21 | struct gpio_config pio_scl;
22 | struct gpio_config pio_sda;
23 | };
24 |
25 | struct i2c_slave {
26 | int bus;
27 | uint8_t address;
28 | void (*isr_tx)(struct i2c_slave *);
29 | void (*isr_rx)(struct i2c_slave *);
30 | void *priv;
31 | };
32 |
33 | int i2c_create(const struct i2c_config *i2c_config);
34 | int i2c_init_read(struct i2c_slave *sl, uint8_t reg, uint8_t *buf, uint32_t len);
35 | int i2c_init_write(struct i2c_slave *sl, uint8_t reg, const uint8_t *buf, uint32_t len);
36 | int i2c_kthread_read(struct i2c_slave *sl, uint8_t reg, uint8_t *buf, uint32_t len);
37 | int i2c_kthread_write(struct i2c_slave *sl, uint8_t reg, const uint8_t *buf, uint32_t len);
38 |
39 | #endif
40 |
41 |
--------------------------------------------------------------------------------
/kernel/drivers/l3gd20.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_L3GD20
2 | #define INC_L3GD20
3 |
4 | struct l3gd20_addr {
5 | const char * name;
6 | const char * spi_name;
7 | const char * spi_cs_name;
8 | uint32_t pio1_base;
9 | uint32_t pio1_pin;
10 | uint32_t pio2_base;
11 | uint32_t pio2_pin;
12 |
13 | };
14 |
15 | void l3gd20_init(struct fnode *dev, const struct l3gd20_addr l3gd20_addr);
16 |
17 | #endif
18 |
19 |
--------------------------------------------------------------------------------
/kernel/drivers/lis3dsh.h:
--------------------------------------------------------------------------------
1 | #ifndef LIS3DSH_INC
2 | #define LIS3DSH_INC
3 | # ifdef CONFIG_DEVLIS3DSH
4 | int lis3dsh_init(uint8_t bus, const struct gpio_config *lis3dsh_cs);
5 | # else
6 | # define lis3dsh_init(...) (0)
7 | # endif
8 | #endif
9 |
--------------------------------------------------------------------------------
/kernel/drivers/lm3s_eth.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Maxime Vincent
18 | *
19 | */
20 |
21 | #include
22 | #include "frosted.h"
23 | #include "gpio.h"
24 | #include "eth.h"
25 |
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include "unicore-mx/cm3/nvic.h"
31 |
32 | #define dbg(...)
33 |
34 | #define ETH_MAX_FRAME (1524) /* Round to multiple of 4 bytes! */
35 | #define ETH_IRQ_PRIO (1)
36 | #define ETH_IRQMASK_RX (1) /* Interrupt Mask for RXINT (bit 0) */
37 |
38 | /* FIXME: Put in board config */
39 | #define BOARD_PHY_RMII /* Whether the board uses RMII or MII */
40 | #define BOARD_phy_addr PHY_LAN8710A_ID /* The PHY ID to be detected on one of the PHY addresses */
41 |
42 | /* Some known PHY-identifiers */
43 | #define PHY_KSZ8021_ID 0x00221556
44 | #define PHY_KS8721_ID 0x00221610
45 | #define PHY_DP83848I_ID 0x20005C90
46 | #define PHY_LAN8710A_ID 0x0007C0F1
47 | #define PHY_DM9161_ID 0x0181B8A0
48 | #define PHY_AM79C875_ID 0x00225540
49 | #define PHY_STE101P_ID 0x00061C50
50 |
51 | struct dev_eth {
52 | struct pico_device dev;
53 | uint32_t rx_prod;
54 | uint32_t rx_cons;
55 | uint8_t mac_addr[6];
56 | uint8_t phy_addr;
57 | };
58 |
59 | static struct module mod_eth = {
60 | .family = FAMILY_DEV,
61 | .name = "ethernet",
62 | };
63 |
64 | static struct dev_eth * dev_eth = NULL;
65 | static const uint8_t default_mac[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
66 |
67 | static uint8_t temp_rx_buf[ETH_MAX_FRAME];
68 |
69 | static int eth_poll(struct pico_device *dev, int loop_score)
70 | {
71 | uint32_t rx_len = 0;
72 | while (eth_rx(temp_rx_buf, &rx_len, ETH_MAX_FRAME) && (loop_score > 0))
73 | {
74 | pico_stack_recv(dev, temp_rx_buf, rx_len);
75 | rx_len = 0;
76 | loop_score--;
77 | }
78 | return loop_score;
79 | }
80 |
81 | static int eth_send(struct pico_device *dev, void * buf, int len)
82 | {
83 | if (eth_tx(buf, len))
84 | return len;
85 | else
86 | return 0;
87 | }
88 |
89 | int pico_eth_start(void)
90 | {
91 | const char ipstr[] = CONFIG_ETH_DEFAULT_IP;
92 | const char nmstr[] = CONFIG_ETH_DEFAULT_NM;
93 | const char gwstr[] = CONFIG_ETH_DEFAULT_GW;
94 | struct pico_ip4 default_ip, default_nm, default_gw, zero;
95 |
96 | zero.addr = 0U;
97 | pico_string_to_ipv4(ipstr, &default_ip.addr);
98 | pico_string_to_ipv4(nmstr, &default_nm.addr);
99 | pico_string_to_ipv4(gwstr, &default_gw.addr);
100 |
101 |
102 | dev_eth = kalloc(sizeof(struct dev_eth));
103 | if (!dev_eth)
104 | return -1;
105 | memset(dev_eth, 0, sizeof(struct dev_eth));
106 |
107 | /* set pico function pointers */
108 | dev_eth->dev.poll = eth_poll;
109 | dev_eth->dev.send = eth_send;
110 |
111 | if (pico_device_init(&dev_eth->dev,"eth0", default_mac) < 0) {
112 | kfree(dev_eth);
113 | return -1;
114 | }
115 | /* Set address/netmask */
116 | pico_ipv4_link_add(&dev_eth->dev, default_ip, default_nm);
117 | /* Set default gateway */
118 | if (default_gw.addr)
119 | pico_ipv4_route_add(zero, zero, default_gw, 1, NULL);
120 |
121 | /* Enabling required interrupt sources.*/
122 |
123 | eth_start();
124 | return 0;
125 |
126 | }
127 |
128 | void eth_isr(void)
129 | {
130 | eth_irq_ack_pending(ETH_IRQMASK_RX);
131 | frosted_tcpip_wakeup();
132 | }
133 |
134 | /* HW initialization */
135 | int ethernet_init(const struct eth_config *conf)
136 | {
137 | (void)conf;
138 | eth_init(0, ETH_CLK_50MHZ); /* does a phy_reset */
139 | nvic_enable_irq(NVIC_ETH_IRQ);
140 | eth_irq_enable(ETH_IRQMASK_RX);
141 | eth_set_mac((uint8_t*)default_mac);
142 | return 0;
143 | }
144 |
--------------------------------------------------------------------------------
/kernel/drivers/lsm303dlhc.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_LSM303DLHC
2 | #define INC_LSM303DLHC
3 |
4 | struct lsm303dlhc_addr {
5 | const char * name;
6 | const char * i2c_name;
7 | uint32_t pio1_base;
8 | uint32_t pio2_base;
9 | uint32_t drdy_base;
10 | uint32_t pio1_pin;
11 | uint32_t pio2_pin;
12 | uint32_t drdy_pin;
13 | uint8_t address;
14 | uint8_t drdy_address;
15 | };
16 |
17 | int lsm303dlhc_init(int bus);
18 |
19 | #endif
20 |
21 |
--------------------------------------------------------------------------------
/kernel/drivers/ltdc.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_LTDC
2 | #define INC_LTDC
3 |
4 | #ifdef CONFIG_LTDC
5 | int ltdc_init(void);
6 | #else
7 | # define ltdc_init() ((-ENOENT))
8 | #endif
9 | #endif
10 |
--------------------------------------------------------------------------------
/kernel/drivers/null.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors:
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "string.h"
23 |
24 | static struct fnode *devnull;
25 | static struct fnode *devzero;
26 |
27 |
28 | static int devnull_read(struct fnode *fno, void *buf, unsigned int len)
29 | {
30 | if (fno == devnull)
31 | return -EPERM;
32 | if (len <= 0)
33 | return len;
34 | memset(buf, 0, sizeof(len));
35 | return (int)len;
36 | }
37 |
38 |
39 | static int devnull_write(struct fnode *fno, const void *buf, unsigned int len)
40 | {
41 | if (fno == devzero)
42 | return -EPERM;
43 | if (len <= 0)
44 | return len;
45 | return len;
46 | }
47 |
48 | static int devnull_poll(struct fnode *fno, uint16_t events, uint16_t *revents)
49 | {
50 | return 1;
51 | }
52 |
53 | static int devnull_open(const char *path, int flags)
54 | {
55 | struct fnode *f = fno_search(path);
56 | return task_filedesc_add(f);
57 |
58 | }
59 |
60 |
61 |
62 | static struct module mod_devnull = {
63 | };
64 |
65 |
66 | void devnull_init(struct fnode *dev)
67 | {
68 | strcpy(mod_devnull.name,"devnull");
69 | mod_devnull.family = FAMILY_FILE;
70 | mod_devnull.ops.open = devnull_open;
71 | mod_devnull.ops.read = devnull_read;
72 | mod_devnull.ops.poll = devnull_poll;
73 | mod_devnull.ops.write = devnull_write;
74 |
75 | devnull = fno_create_wronly(&mod_devnull, "null", dev);
76 | devnull->flags |= FL_TTY;
77 | devzero = fno_create_rdonly(&mod_devnull, "zero", dev);
78 | devzero->flags |= FL_TTY;
79 | register_module(&mod_devnull);
80 | }
81 |
--------------------------------------------------------------------------------
/kernel/drivers/pty.h:
--------------------------------------------------------------------------------
1 | #ifndef PTY_H_INCLUDED
2 | #define PTY_H_INCLUDED
3 |
4 | #ifndef CONFIG_PTY_UNIX
5 | # define ptmx_init() do{}while(0)
6 | #else
7 | int ptmx_init(void);
8 | #endif
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/kernel/drivers/rng.h:
--------------------------------------------------------------------------------
1 | #ifndef RNG_INC
2 | #define RNG_INC
3 | #include "frosted.h"
4 |
5 | #ifdef CONFIG_RNG
6 |
7 | int rng_init(void);
8 | int rng_create(uint32_t base, uint32_t rcc);
9 |
10 | #else
11 |
12 | #define rng_init() (-ENOENT)
13 | #define rng_create(...) (-ENOENT)
14 |
15 | #endif
16 |
17 |
18 | #endif
19 |
--------------------------------------------------------------------------------
/kernel/drivers/sdio.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_SDIO
2 | #define INC_SDIO
3 | #include "frosted.h"
4 | #include "gpio.h"
5 |
6 | struct sdio_config {
7 | uint32_t *base;
8 | uint32_t devidx;
9 | uint32_t *rcc_reg;
10 | uint32_t rcc_en;
11 | uint32_t *rcc_rst_reg;
12 | uint32_t rcc_rst;
13 |
14 | struct gpio_config pio_dat0, pio_dat1, pio_dat2, pio_dat3;
15 | struct gpio_config pio_clk, pio_cmd;
16 |
17 | int card_detect_supported;
18 | struct gpio_config pio_cd;
19 | };
20 |
21 | #ifdef CONFIG_SDIO
22 | int sdio_init(struct sdio_config *conf);
23 | #else
24 | #define sdio_init(x) (-ENOENT)
25 | #endif
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/kernel/drivers/sdram.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_SDRAM
2 | #define INC_SDRAM
3 |
4 | #if defined CONFIG_SDRAM
5 | int sdram_init(void);
6 | #else
7 | #define sdram_init() (-ENOENT)
8 | #endif
9 |
10 | #endif
11 |
--------------------------------------------------------------------------------
/kernel/drivers/socket_un.c:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 | #include
3 |
4 | static struct module mod_socket_un;
5 | struct fnode FNO_SOCKUN_STUB = {
6 | .owner = &mod_socket_un
7 | };
8 |
9 | static int sock_check_fd(int fd, struct fnode **fno)
10 | {
11 | *fno = task_filedesc_get(fd);
12 |
13 | if (!fno)
14 | return -1;
15 |
16 | if (fd < 0)
17 | return -1;
18 | if ((*fno)->owner != &mod_socket_un)
19 | return -1;
20 |
21 | return 0;
22 | }
23 |
24 | static int sock_poll(int fd, uint16_t events, uint16_t *revents)
25 | {
26 | *revents = events;
27 | return 1;
28 | }
29 |
30 |
31 | static int sock_close(int fd)
32 | {
33 | struct fnode *fno;
34 | if (sock_check_fd(fd, &fno))
35 | return -1;
36 | kprintf("## Closed UNIX socket!\n");
37 | /* TODO */
38 | return 0;
39 | }
40 |
41 | int sock_socket(int domain, int type, int protocol)
42 | {
43 | int fd = -1;
44 | kprintf("## Opened UNIX socket!\n");
45 | fd = task_filedesc_add(&FNO_SOCKUN_STUB);
46 | return fd;
47 | }
48 | int sock_recvfrom(int fd, void *buf, unsigned int len, int flags, struct sockaddr *addr, unsigned int *addrlen)
49 | {
50 | return -1;
51 | }
52 |
53 | int sock_sendto(int fd, const void *buf, unsigned int len, int flags, struct sockaddr *addr, unsigned int addrlen)
54 | {
55 | return -1;
56 | }
57 | int sock_bind(int fd, struct sockaddr *addr, unsigned int addrlen)
58 | {
59 | return -1;
60 | }
61 |
62 | int sock_accept(int fd, struct sockaddr *addr, unsigned int *addrlen)
63 | {
64 | return -1;
65 | }
66 |
67 | int sock_connect(int fd, struct sockaddr *addr, unsigned int addrlen)
68 | {
69 | return -1;
70 | }
71 |
72 | int sock_listen(int fd, int backlog)
73 | {
74 | return -1;
75 | }
76 |
77 | int sock_shutdown(int fd, uint16_t how)
78 | {
79 | return -1;
80 | }
81 |
82 |
83 | void socket_un_init(void)
84 | {
85 | mod_socket_un.family = FAMILY_UNIX;
86 | strcpy(mod_socket_un.name,"un");
87 | mod_socket_un.ops.poll = sock_poll;
88 | mod_socket_un.ops.close = sock_close;
89 |
90 | mod_socket_un.ops.socket = sock_socket;
91 | mod_socket_un.ops.connect = sock_connect;
92 | mod_socket_un.ops.accept = sock_accept;
93 | mod_socket_un.ops.bind = sock_bind;
94 | mod_socket_un.ops.listen = sock_listen;
95 | mod_socket_un.ops.recvfrom = sock_recvfrom;
96 | mod_socket_un.ops.sendto = sock_sendto;
97 | mod_socket_un.ops.shutdown = sock_shutdown;
98 |
99 | register_module(&mod_socket_un);
100 | register_addr_family(&mod_socket_un, FAMILY_UNIX);
101 | }
102 |
103 |
104 |
105 |
--------------------------------------------------------------------------------
/kernel/drivers/spi.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_SPI
2 | #define INC_SPI
3 | #include "dma.h"
4 | #include "gpio.h"
5 |
6 | struct spi_config {
7 | int idx;
8 | uint32_t base;
9 | uint32_t irq;
10 | uint32_t rcc;
11 | uint32_t baudrate;
12 | uint8_t polarity;
13 | uint8_t phase;
14 | uint8_t rx_only;
15 | uint8_t bidir_mode;
16 | uint16_t dff_16;
17 | uint8_t enable_software_slave_management;
18 | uint8_t send_msb_first;
19 |
20 | /* DMA Config */
21 | uint32_t dma_rcc;
22 | struct dma_config tx_dma;
23 | struct dma_config rx_dma;
24 |
25 | /* Pin muxing */
26 | struct gpio_config pio_sck;
27 | struct gpio_config pio_miso;
28 | struct gpio_config pio_mosi;
29 | struct gpio_config pio_nss;
30 | };
31 |
32 | struct spi_slave {
33 | uint8_t bus;
34 | void (*isr)(struct spi_slave *);
35 | void *priv;
36 | };
37 |
38 | int devspi_create(const struct spi_config *spi_config);
39 | int devspi_xfer(struct spi_slave *spi, const char *obuf, char *ibuf, unsigned int len);
40 |
41 | #endif
42 |
43 |
--------------------------------------------------------------------------------
/kernel/drivers/stm32_dma.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors:
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 | #include
24 | #include "cirbuf.h"
25 | #include
26 |
27 | #include "dma.h"
28 |
29 |
30 | void init_dma(const struct dma_config * dma, uint32_t ptr, uint32_t len)
31 | {
32 | dma_stream_reset(dma->base, dma->stream);
33 |
34 | dma_set_transfer_mode(dma->base, dma->stream, dma->dirn);
35 | dma_set_priority(dma->base, dma->stream, dma->prio);
36 |
37 | dma_set_peripheral_address(dma->base, dma->stream, dma->paddr);
38 | dma_disable_peripheral_increment_mode(dma->base, dma->stream);
39 | dma_set_peripheral_size(dma->base, dma->stream, dma->psize);
40 |
41 | dma_enable_memory_increment_mode(dma->base, dma->stream);
42 | dma_set_memory_size(dma->base, dma->stream, dma->msize);
43 |
44 | dma_enable_direct_mode(dma->base, dma->stream);
45 | dma_set_dma_flow_control(dma->base, dma->stream);
46 |
47 | dma_channel_select(dma->base,dma->stream,dma->channel);
48 |
49 | dma_set_memory_address(dma->base, dma->stream, ptr);
50 | dma_set_number_of_data(dma->base, dma->stream, len);
51 | dma_enable_stream(dma->base, dma->stream);
52 | }
53 |
--------------------------------------------------------------------------------
/kernel/drivers/stm32_lowpower.c:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 | #include "unicore-mx/cm3/nvic.h"
3 | #include "unicore-mx/cm3/systick.h"
4 | #include "unicore-mx/cm3/scb.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | #define WFE() __asm__ volatile ("wfe")
15 | #if CONFIG_SYS_CLOCK == 48000000
16 | # define STM32_CLOCK RCC_CLOCK_3V3_48MHZ
17 | #elif CONFIG_SYS_CLOCK == 84000000
18 | # define STM32_CLOCK RCC_CLOCK_3V3_84MHZ
19 | #elif CONFIG_SYS_CLOCK == 100000000
20 | # define STM32_CLOCK RCC_CLOCK_3V3_100MHZ
21 | #elif CONFIG_SYS_CLOCK == 120000000
22 | # define STM32_CLOCK RCC_CLOCK_3V3_120MHZ
23 | #elif CONFIG_SYS_CLOCK == 168000000
24 | # define STM32_CLOCK RCC_CLOCK_3V3_168MHZ
25 | #else
26 | # error No valid clock speed selected
27 | #endif
28 |
29 |
30 | int lowpower_init(void)
31 | {
32 | rcc_periph_clock_enable(RCC_PWR);
33 | rcc_periph_clock_enable(RCC_RTC);
34 |
35 | /* Disable write protection in the backup range */
36 | PWR_CR |= PWR_CR_DBP;
37 |
38 | rtc_unlock();
39 | nvic_clear_pending_irq(NVIC_RTC_WKUP_IRQ);
40 | nvic_disable_irq(NVIC_RTC_WKUP_IRQ);
41 | RTC_ISR &= ~RTC_ISR_WUTF;
42 | RTC_CR &= ~(RTC_CR_WUTIE | RTC_CR_WUTE);
43 | rtc_lock();
44 |
45 | return 0;
46 | }
47 |
48 |
49 | int lowpower_sleep(int stdby, uint32_t interval)
50 | {
51 | uint32_t rtc_wup;
52 | uint32_t err;
53 |
54 | if (interval < 1)
55 | return -1;
56 |
57 | rtc_wup = (interval * 2048) - 1;
58 |
59 | irq_off();
60 | rcc_periph_clock_enable(RCC_PWR);
61 | rcc_periph_clock_enable(RCC_RTC);
62 |
63 | /* Disable write protection in the backup range */
64 | pwr_disable_backup_domain_write_protect();
65 |
66 | /* Enable RTC */
67 | RCC_BDCR |= RCC_BDCR_RTCEN;
68 |
69 | #ifndef CONFIG_LSE32K
70 | /* Enable LSI */
71 | rcc_osc_on(RCC_LSI);
72 | rcc_wait_for_osc_ready(RCC_LSI);
73 |
74 | /* Select LSI as RTC clock source */
75 | RCC_BDCR &= ~RCC_BDCR_RTCSEL_MASK << RCC_BDCR_RTCSEL_SHIFT;
76 | RCC_BDCR |= RCC_BDCR_RTCSEL_LSI << RCC_BDCR_RTCSEL_SHIFT;
77 | #else
78 | /* Enable LSE */
79 | rcc_osc_bypass_disable(RCC_LSE);
80 | rcc_osc_on(RCC_LSE);
81 | rcc_wait_for_osc_ready(RCC_LSE);
82 |
83 | /* Select LSE as RTC clock source */
84 | RCC_BDCR &= ~RCC_BDCR_RTCSEL_MASK << RCC_BDCR_RTCSEL_SHIFT;
85 | RCC_BDCR |= RCC_BDCR_RTCSEL_LSE << RCC_BDCR_RTCSEL_SHIFT;
86 | #endif
87 |
88 | /* Set up watchdog timer */
89 | rtc_unlock();
90 | rtc_enable_wakeup_timer();
91 |
92 | rtc_set_wakeup_time((interval - 1), RTC_CR_WUCLKSEL_SPRE);
93 |
94 | rtc_lock();
95 | systick_counter_disable();
96 | systick_interrupt_disable();
97 |
98 | SCB_SCR |= SCB_SCR_SEVEONPEND;
99 | SCB_SCR |= SCB_SCR_SLEEPDEEP;
100 |
101 | if (stdby) {
102 | pwr_clear_wakeup_flag();
103 | pwr_clear_standby_flag();
104 | pwr_set_standby_mode();
105 | } else {
106 | pwr_clear_wakeup_flag();
107 | pwr_voltage_regulator_low_power_in_stop();
108 | PWR_CR |= PWR_CR_FPDS;
109 | }
110 |
111 | irq_on();
112 |
113 | WFE();
114 | WFE();
115 |
116 | SCB_SCR &= ~SCB_SCR_SLEEPDEEP;
117 | pwr_clear_wakeup_flag();
118 |
119 | #ifdef CLOCK_12MHZ
120 | rcc_clock_setup_hse_3v3(&rcc_hse_12mhz_3v3[STM32_CLOCK]);
121 | #else
122 | rcc_clock_setup_hse_3v3(&rcc_hse_8mhz_3v3[STM32_CLOCK]);
123 | #endif
124 |
125 | systick_interrupt_enable();
126 | systick_counter_enable();
127 | rcc_periph_clock_enable(RCC_PWR);
128 | rcc_periph_clock_enable(RCC_RTC);
129 | nvic_enable_irq(NVIC_RTC_WKUP_IRQ);
130 |
131 | /* Disable write protection in the backup range */
132 | pwr_disable_backup_domain_write_protect();
133 |
134 | /* Disable RTC */
135 | RCC_BDCR &= ~RCC_BDCR_RTCEN;
136 |
137 | jiffies += interval * 1000;
138 |
139 | return 0;
140 | }
141 |
142 | void rtc_wkup_isr(void)
143 | {
144 | /* Enable RTC */
145 | RCC_BDCR |= RCC_BDCR_RTCEN;
146 | rtc_unlock();
147 | nvic_clear_pending_irq(NVIC_RTC_WKUP_IRQ);
148 | nvic_disable_irq(NVIC_RTC_WKUP_IRQ);
149 | RTC_ISR &= ~RTC_ISR_WUTF;
150 | RTC_CR &= ~(RTC_CR_WUTIE | RTC_CR_WUTE);
151 | rtc_lock();
152 | }
153 |
154 |
--------------------------------------------------------------------------------
/kernel/drivers/stm32_rng.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: brabo
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 | #if defined(CONFIG_FRAND)
24 | # include "frand.h"
25 | # include "fortuna.h"
26 | # include "crypto/sha256.h"
27 | #endif
28 | #include
29 | #include "rng.h"
30 |
31 | #include
32 | #include
33 | #include
34 | #include
35 | #define CLOCK_ENABLE(C) rcc_periph_clock_enable(C);
36 |
37 | struct dev_rng {
38 | struct device *dev;
39 | uint32_t base;
40 | uint32_t *random;
41 | };
42 |
43 | #define MAX_RNGS 1
44 |
45 | #if defined(CONFIG_FRAND)
46 | uint32_t req;
47 | #endif
48 |
49 | static struct dev_rng DEV_RNG[MAX_RNGS];
50 |
51 | #if defined(CONFIG_RNG)
52 | static int devrng_read(struct fnode *fno, void *buf, unsigned int len);
53 | #endif
54 |
55 | static struct module mod_devrng = {
56 | .family = FAMILY_FILE,
57 | #if defined(CONFIG_RNG)
58 | .name = "urandom",
59 | .ops.open = device_open,
60 | .ops.read = devrng_read,
61 | #endif
62 | };
63 |
64 | #if defined(CONFIG_RNG)
65 | static int devrng_read(struct fnode *fno, void *buf, unsigned int len)
66 | {
67 | struct dev_rng *rng;
68 | int i;
69 | uint32_t tmp;
70 |
71 | if (len == 0)
72 | return len;
73 |
74 | rng = (struct dev_rng *)FNO_MOD_PRIV(fno, &mod_devrng);
75 |
76 | if (!rng)
77 | return -1;
78 |
79 | mutex_lock(rng->dev->mutex);
80 |
81 | uint32_t error_bits = 0;
82 | error_bits = RNG_SR_SEIS | RNG_SR_CEIS | RNG_SR_SECS | RNG_SR_CECS;
83 |
84 | for (i = 0; i < len; i+=4) {
85 | uint32_t *rnd_dst = (uint32_t *)((uint8_t *)buf + i);
86 | if (((RNG_SR & error_bits) != 0) ||
87 | ((RNG_SR & RNG_SR_DRDY) != 1)) {
88 | rng->random = (uint32_t *)buf;
89 | rng_enable_interrupt();
90 | rng->dev->task = this_task();
91 | mutex_unlock(rng->dev->mutex);
92 | task_suspend();
93 | return SYS_CALL_AGAIN;
94 | }
95 | rng_get_random(rnd_dst);
96 | }
97 | if (i < len) {
98 | rng_get_random(&tmp);
99 | memcpy(buf + i, &tmp, len - i);
100 | }
101 | mutex_unlock(rng->dev->mutex);
102 | return len;
103 | }
104 | #endif
105 |
106 | void rng_isr(void)
107 | {
108 | struct dev_rng *rng = &DEV_RNG[0];
109 | uint32_t error_bits = 0;
110 | error_bits = RNG_SR_SEIS | RNG_SR_CEIS | RNG_SR_SECS | RNG_SR_CECS;
111 | if ((RNG_SR & RNG_SR_SEIS) != 0) {
112 | if ((RNG_SR & RNG_SR_DRDY) == 1) {
113 | uint32_t dummy;
114 | rng_get_random(&dummy);
115 | }
116 | rng_disable();
117 | rng_enable();
118 | RNG_SR &= ~RNG_SR_SEIS;
119 | }
120 | if ((RNG_SR & RNG_SR_CEIS) != 0) {
121 | rcc_periph_reset_pulse(RST_RNG);
122 | rng_disable();
123 | rng_enable();
124 | RNG_SR &= ~RNG_SR_CEIS;
125 | }
126 | if (((RNG_SR & error_bits) == 0) && ((RNG_SR & RNG_SR_DRDY) == 1)) {
127 | uint32_t random;
128 | rng_get_random(&random);
129 | #if defined(CONFIG_FRAND)
130 | fortuna_accu(0, 0, (uint8_t *)&random, 4);
131 | if (req == 0) {
132 | rng_disable_interrupt();
133 | } else {
134 | req--;
135 | }
136 | #else
137 | memcpy(rng->random, &random, 4);
138 | rng_disable_interrupt();
139 | task_resume(rng->dev->task);
140 | #endif
141 | }
142 | }
143 |
144 | #if defined(CONFIG_RNG)
145 | int rng_create(uint32_t base, uint32_t rcc)
146 | {
147 | static uint32_t id = 0;
148 | struct dev_rng *r = &DEV_RNG[id];
149 | struct fnode *devfs;
150 | CLOCK_ENABLE(rcc);
151 |
152 | devfs = fno_search("/dev");
153 | if (!devfs)
154 | return -ENOENT;
155 | r->dev = device_fno_init(&mod_devrng, mod_devrng.name, devfs, FL_RDONLY, r);
156 | r->base = base;
157 | rng_enable();
158 | return id++;
159 | }
160 | #endif
161 |
162 | #if defined(CONFIG_FRAND)
163 | static const struct frand_ops rng_frandops = { };
164 |
165 | static struct frand_info rng_info = { .frandops = (struct frand_ops *)&rng_frandops };
166 | #endif
167 |
168 | int rng_init(void)
169 | {
170 | register_module(&mod_devrng);
171 | #if defined(CONFIG_FRAND)
172 | register_frand(&rng_info);
173 | req = FORTUNA_ENCRYPT_KEY_SIZE * ((SHA256_DIGEST_SIZE / sizeof(word32)) * (SHA256_BLOCK_SIZE / sizeof(word32)));
174 | rng_enable_interrupt();
175 | #endif
176 | return 0;
177 | }
178 |
--------------------------------------------------------------------------------
/kernel/drivers/stm32_sdio.h:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 | /* this define lets the init code know that you are using a GPIO as a card
3 | * detect pin */
4 | #define SDIO_HAS_CARD_DETECT
5 |
6 | enum SDIO_CLOCK_DIV {
7 | SDIO_24MHZ = 0,
8 | SDIO_16MHZ,
9 | SDIO_12MHZ,
10 | SDIO_8MHZ,
11 | SDIO_4MHZ,
12 | SDIO_1MHZ,
13 | SDIO_400KHZ
14 | };
15 |
16 | enum SDIO_POWER_STATE {
17 | SDIO_POWER_ON,
18 | SDIO_POWER_OFF
19 | };
20 |
21 | #define SDIO_CARD_CCS(c) (((c)->ocr & 0x40000000) != 0)
22 | #define SDIO_CARD_UHS2(c) (((c)->ocr & 0x40000000) != 0)
23 | #define SDIO_CARD_LVOK(c) (((c)->ocr & 0x01000000) != 0)
24 |
25 | typedef struct SDIO_CARD_DATA {
26 | uint32_t props;
27 | uint32_t ocr;
28 | uint32_t cid[4];
29 | uint32_t csd[4];
30 | uint32_t scr[2];
31 | uint32_t status[16];
32 | uint32_t size;
33 | uint16_t rca;
34 | } * SDIO_CARD;
35 |
36 | struct dev_sd {
37 | struct device *dev;
38 | uint32_t base;
39 | uint32_t *rcc_rst_reg;
40 | uint32_t rcc_rst;
41 | SDIO_CARD card;
42 | };
43 |
44 | int stm32_sdio_bus(struct dev_sd *sd, int bits, enum SDIO_CLOCK_DIV freq);
45 | int stm32_sdio_init(void);
46 | void stm32_sdio_reset(struct dev_sd *sd, enum SDIO_POWER_STATE state);
47 | SDIO_CARD stm32_sdio_open(struct dev_sd *sd);
48 | int stm32_sdio_command(struct dev_sd *sd, uint32_t cmd, uint32_t arg);
49 | int stm32_sdio_readblock(SDIO_CARD, uint32_t lba, uint8_t *buf);
50 | int stm32_sdio_writeblock(SDIO_CARD, uint32_t lba, uint8_t *buf);
51 | //int stm32_sdio_status(SDIO_CARD);
52 | void stm32_sdio_print_log(int console, int number_of_entries);
53 | const char *stm32_sdio_errmsg(int err);
54 | uint32_t stm32_sdio_bit_slice(uint32_t a[], int bits, int msb, int lsb);
55 |
56 | /* API for sd_bus clock setting */
57 | enum SD_CLOCK_DIV {
58 | CLOCK_24MHZ = 0,
59 | CLOCK_16MHZ,
60 | CLOCK_12MHZ,
61 | CLOCK_8MHZ,
62 | CLOCK_4MHZ,
63 | CLOCK_1MHZ,
64 | CLOCK_400KHZ
65 | };
66 |
67 | //int stm32_sd_bus(int bits, enum SD_CLOCK_DIV freq);
68 |
--------------------------------------------------------------------------------
/kernel/drivers/stm32f4_adc.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors:
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 | #include
24 | #include "ioctl.h"
25 | #include "dma.h"
26 | #include "adc.h"
27 | #ifdef STM32F4
28 | #include
29 | #include
30 | #include
31 | #include
32 | # define CLOCK_ENABLE(C) rcc_periph_clock_enable(C);
33 | #endif
34 |
35 |
36 | struct dev_adc{
37 | struct device * dev;
38 | uint32_t base;
39 | uint32_t irq;
40 | uint8_t channel_array[NUM_ADC_CHANNELS];
41 | uint8_t num_channels;
42 | int conversion_done;
43 | uint16_t samples[NUM_ADC_CHANNELS];
44 | const struct dma_config * dma_config;
45 | };
46 |
47 | #define MAX_ADCS 1
48 |
49 | static struct dev_adc DEV_ADC[MAX_ADCS];
50 |
51 | static int devadc_read(struct fnode * fno, void *buf, unsigned int len);
52 |
53 | static struct module mod_devadc = {
54 | .family = FAMILY_FILE,
55 | .name = "adc",
56 | .ops.open = device_open,
57 | .ops.read = devadc_read,
58 | };
59 |
60 | void dma2_stream0_isr()
61 | {
62 | struct dev_adc * adc = &DEV_ADC[0];
63 |
64 | if((DMA2_LISR & DMA_LISR_TCIF0) != 0)
65 | {
66 | dma_clear_interrupt_flags(DMA2, DMA_STREAM0, DMA_LISR_TCIF0);
67 | adc_disable_dma(adc->base);
68 | adc->conversion_done = 1;
69 | if (adc->dev->task != NULL)
70 | task_resume(adc->dev->task);
71 | }
72 | }
73 |
74 | static int devadc_read(struct fnode *fno, void *buf, unsigned int len)
75 | {
76 | int i;
77 | struct dev_adc *adc;
78 |
79 | if (len <= 0)
80 | return len;
81 |
82 | adc = (struct dev_adc *)FNO_MOD_PRIV(fno, &mod_devadc);
83 | if (!adc)
84 | return -1;
85 |
86 | mutex_lock(adc->dev->mutex);
87 |
88 | if (adc->conversion_done == 0)
89 | {
90 | adc_enable_dma(adc->base);
91 | adc_start_conversion_regular(adc->base);
92 | adc->dev->task = this_task();
93 | task_suspend();
94 | mutex_unlock(adc->dev->mutex);
95 | return SYS_CALL_AGAIN;
96 | }
97 |
98 | if(len > (adc->num_channels * 2))
99 | {
100 | len = adc->num_channels * 2;
101 | }
102 |
103 | memcpy(buf, adc->samples, len);
104 | adc->conversion_done = 0;
105 | mutex_unlock(adc->dev->mutex);
106 | return len;
107 | }
108 |
109 | static void adc_fno_init(struct fnode *dev, uint32_t n, const struct adc_config * addr)
110 | {
111 | struct dev_adc *a = &DEV_ADC[n];
112 | char name[6] = "adc";
113 | name[4] = '0' + (char)n;
114 | name[5] = '\0';
115 | a->dev = device_fno_init(&mod_devadc, name, dev, FL_RDONLY, a);
116 | a->base = addr->base;
117 | memcpy(a->channel_array, addr->channel_array, NUM_ADC_CHANNELS);
118 | a->num_channels = addr->num_channels;
119 | a->conversion_done = 0;
120 | }
121 |
122 | void adc_init(const struct adc_config adc_configs[], int num_adcs)
123 | {
124 | int i;
125 | struct fnode *dev = fno_search("/dev");
126 |
127 | if (!dev)
128 | return;
129 | for (i = 0; i < num_adcs; i++)
130 | {
131 | if (adc_configs[i].base == 0)
132 | continue;
133 |
134 | adc_fno_init(dev, i, &adc_configs[i]);
135 | CLOCK_ENABLE(adc_configs[i].rcc);
136 | CLOCK_ENABLE(adc_configs[i].dma_rcc);
137 |
138 | init_dma(&adc_configs[i].dma, (uint32_t) DEV_ADC[i].samples, adc_configs[i].num_channels);
139 |
140 | dma_enable_circular_mode(adc_configs[i].dma.base, adc_configs[i].dma.stream);
141 |
142 | dma_enable_transfer_complete_interrupt(adc_configs[i].dma.base, adc_configs[i].dma.stream);
143 | nvic_set_priority(adc_configs[i].dma.irq, 1);
144 | nvic_enable_irq(adc_configs[i].dma.irq);
145 |
146 | adc_set_resolution(adc_configs[i].dma.base, ADC_CR1_RES_12BIT);
147 | adc_power_off(adc_configs[i].base);
148 | adc_disable_external_trigger_regular(adc_configs[i].base);
149 | adc_set_sample_time_on_all_channels(adc_configs[i].base, ADC_SMPR_SMP_480CYC);
150 | adc_set_regular_sequence(adc_configs[i].base, adc_configs[i].num_channels, adc_configs[i].channel_array);
151 | adc_enable_scan_mode(adc_configs[i].base);
152 | adc_set_single_conversion_mode(adc_configs[i].base);
153 | adc_eoc_after_each(adc_configs[i].base);
154 | adc_set_dma_terminate(adc_configs[i].base);
155 | adc_set_right_aligned(adc_configs[i].base);
156 | adc_power_on(adc_configs[i].base);
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/kernel/drivers/stmpe811.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_STMPE811
2 | #define INC_STMPE811
3 |
4 | #include "gpio.h"
5 |
6 | struct ts_config {
7 | struct gpio_config gpio;
8 | uint8_t bus;
9 | };
10 |
11 |
12 | int stmpe811_init(struct ts_config *ts);
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/kernel/drivers/tty_console.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 | #include
24 | #include "framebuffer.h"
25 |
26 | #define KBD_PATH "/dev/kbd0"
27 | #define FBCON_PATH "/dev/fbcon"
28 |
29 | #define KBD_MOD "usbkbd"
30 | #define FBCON_MOD "fbcon"
31 |
32 |
33 | static struct tty_console {
34 | struct device *dev;
35 | struct fnode *kbd;
36 | struct fnode *fbcon;
37 | struct module *mod_kbd;
38 | struct module *mod_fbcon;
39 | uint16_t pid;
40 | } TTY;
41 |
42 | static int tty_read(struct fnode *fno, void *buf, unsigned int len);
43 | static int tty_poll(struct fnode *fno, uint16_t events, uint16_t *revents);
44 | static int tty_write(struct fnode *fno, const void *buf, unsigned int len);
45 | static int tty_seek(struct fnode *fno, int off, int whence);
46 | static void tty_attach(struct fnode *fno, int pid);
47 |
48 | static struct module mod_ttycon = {
49 | .family = FAMILY_DEV,
50 | .name = "tty",
51 | .ops.open = device_open,
52 | .ops.read = tty_read,
53 | .ops.poll = tty_poll,
54 | .ops.write = tty_write,
55 | .ops.seek = tty_seek,
56 | .ops.tty_attach = tty_attach
57 | };
58 |
59 | static void devfile_create(void)
60 | {
61 | char name[5] = "tty";
62 | struct fnode *devfs = fno_search("/dev");
63 | if (!devfs)
64 | return;
65 | TTY.dev = device_fno_init(&mod_ttycon, name, devfs, FL_TTY, &TTY);
66 | }
67 |
68 | int tty_console_init(void)
69 | {
70 | TTY.mod_kbd = module_search(KBD_MOD);
71 | TTY.mod_fbcon = module_search(FBCON_MOD);
72 | if(!TTY.mod_kbd || !TTY.mod_fbcon)
73 | return -1;
74 | TTY.kbd = fno_search(KBD_PATH);
75 | TTY.fbcon = fno_search(FBCON_PATH);
76 | devfile_create();
77 | return 0;
78 | }
79 |
80 | static void tty_send_break(void *arg)
81 | {
82 | int *pid = (int *)(arg);
83 | if (pid)
84 | task_kill(*pid, 2);
85 | }
86 |
87 | static int tty_read(struct fnode *fno, void *buf, unsigned int len)
88 | {
89 | int ret, i;
90 | if (!TTY.kbd)
91 | TTY.kbd = fno_search(KBD_PATH);
92 | if (!TTY.kbd)
93 | return 0;
94 | ret = TTY.mod_kbd->ops.read(TTY.kbd, buf, len);
95 | if (TTY.pid > 1) {
96 | for (i = 0; i < ret; i++) {
97 | if (((uint8_t *)buf)[i] == 0x03) /* Ctrl + c*/
98 | tasklet_add(tty_send_break, &TTY.pid);
99 | }
100 | }
101 | return ret;
102 | }
103 |
104 | static int tty_poll(struct fnode *fno, uint16_t events, uint16_t *revents)
105 | {
106 | if (!TTY.kbd)
107 | TTY.kbd = fno_search(KBD_PATH);
108 | if (!TTY.kbd)
109 | return 0;
110 | return TTY.mod_kbd->ops.poll(TTY.kbd, events, revents);
111 | }
112 |
113 | static int tty_write(struct fnode *fno, const void *buf, unsigned int len)
114 | {
115 | if (!TTY.fbcon)
116 | TTY.fbcon = fno_search(FBCON_PATH);
117 | return TTY.mod_fbcon->ops.write(TTY.fbcon, buf, len);
118 | }
119 |
120 | static int tty_seek(struct fnode *fno, int off, int whence)
121 | {
122 | if (!TTY.fbcon)
123 | TTY.fbcon = fno_search(FBCON_PATH);
124 | if (!TTY.fbcon)
125 | return -ENOENT;
126 | return TTY.mod_fbcon->ops.seek(TTY.fbcon, off, whence);
127 | }
128 |
129 | static void tty_attach(struct fnode *fno, int pid)
130 | {
131 | if (!TTY.fbcon)
132 | TTY.fbcon = fno_search(FBCON_PATH);
133 | if (!TTY.fbcon)
134 | return;
135 | TTY.mod_fbcon->ops.tty_attach(TTY.fbcon, pid);
136 | TTY.pid = pid;
137 | }
138 |
139 |
--------------------------------------------------------------------------------
/kernel/drivers/tty_console.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef INC_TTY_CONSOLE
3 | #define INC_TTY_CONSOLE
4 | #include "frosted.h"
5 | #ifdef CONFIG_DEVTTY_CONSOLE
6 | int tty_console_init(void);
7 | #else
8 | #define tty_console_init() (-ENOENT)
9 | #endif
10 |
11 |
12 | #endif
13 |
14 |
--------------------------------------------------------------------------------
/kernel/drivers/uart.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_UART
2 | #define INC_UART
3 |
4 | #include "frosted.h"
5 | #include "gpio.h"
6 |
7 | /* TX, RX, RTS, CTS, CK*/
8 | #define MAX_UART_PINS 5
9 |
10 | struct uart_config {
11 | uint8_t devidx;
12 | uint32_t base;
13 | uint32_t irq;
14 | uint32_t rcc;
15 | uint32_t baudrate;
16 | uint8_t stop_bits;
17 | uint8_t data_bits;
18 | uint8_t parity;
19 | uint8_t flow;
20 | struct gpio_config pio_rx;
21 | struct gpio_config pio_tx;
22 | struct gpio_config pio_cts;
23 | struct gpio_config pio_rts;
24 | };
25 |
26 | #ifdef CONFIG_DEVUART
27 | int uart_init(void);
28 | int uart_create(const struct uart_config *cfg);
29 | #else
30 | #define uart_init() (-ENOENT)
31 | #define uart_create(x) (-ENOENT)
32 | #endif
33 |
34 |
35 | #endif
36 |
37 |
--------------------------------------------------------------------------------
/kernel/drivers/uart_dev.h:
--------------------------------------------------------------------------------
1 | #ifndef UART_DEV_INCLUDE /* <--- keep the same name for guard across archs for compile-time sanity */
2 | #define UART_DEV_INCLUDE
3 | #define UART_FR_RXFE (0x10)
4 | #define UART_FR_TXFF (0x20)
5 |
6 | #ifdef STELLARIS
7 | #define UART_IM_RXIM (0x10)
8 | #else
9 | #define UART_IM_RXIM (0x10)
10 | #endif
11 | #define UART_IC_RXIC (0x10)
12 |
13 | #define UART_DR(baseaddr) (*(uint32_t *)(baseaddr))
14 | #define UART_IR(baseaddr) (*(((uint32_t *)(baseaddr)) + 1))
15 | #define UART_FR(baseaddr) (*(((uint32_t *)(baseaddr))+(0x18>>2)))
16 | #define UART_IC(baseaddr) (*(((uint32_t *)(baseaddr))+(0x44>>2)))
17 | #define UART_IM(baseaddr) (*(((uint32_t *)(baseaddr))+(0x38>>2)))
18 |
19 | #define UART_RXREG UART_DR
20 | #define UART_TXREG UART_DR
21 |
22 | static inline char uart_rx(uint32_t *base)
23 | {
24 | char byte = UART_RXREG(base);
25 | return byte;
26 | }
27 |
28 | static inline int uart_poll_rx(uint32_t *base)
29 | {
30 | return (!(UART_FR(base) & UART_FR_RXFE));
31 | }
32 |
33 | static inline void uart_enter_irq(uint32_t *base)
34 | {
35 | UART_IC(base) = UART_IC_RXIC;
36 | }
37 | /*
38 | static inline void uart_init(uint32_t *base)
39 | {
40 | UART_IR(base) = 0;
41 | UART_IM(base) = UART_IM_RXIM;
42 | }
43 | */
44 | static inline void uart_tx(uint32_t *base, char c)
45 | {
46 | UART_TXREG(base) = c;
47 | }
48 | #endif
49 |
--------------------------------------------------------------------------------
/kernel/drivers/usb.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_USB
2 | #define INC_USB
3 | #include "frosted.h"
4 | #include "gpio.h"
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | #define USB_DEV_FS 0
12 | #define USB_DEV_HS 1
13 |
14 | #define USB_MODE_GUEST 1
15 | #define USB_MODE_HOST 2
16 |
17 | typedef void (*usb_host_driver_probe_callback)(
18 | struct usbh_device *dev,
19 | const struct usb_device_descriptor *device_desc,
20 | const struct usb_config_descriptor *config_desc);
21 |
22 | typedef void (*usb_host_interface_removed_callback)(
23 | struct usbh_device *dev, uint8_t bInterfaceNumber);
24 |
25 | int usb_host_driver_register(struct module *owner,
26 | usb_host_driver_probe_callback probe);
27 |
28 | int usb_host_claim_interface(struct module *owner,
29 | usbh_device *dev, uint8_t bInterfaceNumber,
30 | usb_host_interface_removed_callback removed);
31 |
32 | int usb_host_release_interface(usbh_device *dev,
33 | uint8_t bInterfaceNumber);
34 |
35 | struct usb_pio_config_fs {
36 | struct gpio_config pio_vbus;
37 | struct gpio_config pio_dm;
38 | struct gpio_config pio_dp;
39 | struct gpio_config pio_phy;
40 | };
41 |
42 | struct usb_pio_config_hs {
43 | struct gpio_config ulpi_data[8];
44 | struct gpio_config ulpi_clk;
45 | struct gpio_config ulpi_dir;
46 | struct gpio_config ulpi_next;
47 | struct gpio_config ulpi_step;
48 | };
49 |
50 | struct usb_config {
51 | unsigned int dev_type;
52 | unsigned int otg_mode;
53 |
54 | union usb_pio_config {
55 | struct usb_pio_config_fs *fs;
56 | struct usb_pio_config_hs *hs;
57 | } pio;
58 | };
59 |
60 | #ifdef CONFIG_DEVUSB
61 | int usb_init(struct usb_config *conf);
62 | int usbdev_start(usbd_device **_usbd_dev, unsigned int dev,
63 | const struct usbd_info *info);
64 | #else
65 | # define usb_init(x) ((-ENOENT))
66 | # define usbdev_start(...) ((-ENOENT))
67 | #endif
68 |
69 |
70 | #ifdef CONFIG_DEV_USBETH
71 | int usb_ethernet_init(unsigned int dev);
72 | #else
73 | # define usb_ethernet_init(x) ((-ENOENT))
74 | #endif
75 |
76 | #endif
77 |
--------------------------------------------------------------------------------
/kernel/drivers/usb/usbh_drivers.h:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 | #include "device.h"
3 | #ifndef USBH_DRIVERS_H
4 | #define USBH_DRIVERS_H
5 |
6 | /* Put your driver initalizers here */
7 |
8 | extern void usb_kbd_init(void);
9 |
10 |
11 | static inline void usbh_drivers_init(void)
12 | {
13 | #ifdef CONFIG_DEV_USBH_KBD
14 | usb_kbd_init();
15 | #endif
16 | }
17 |
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/kernel/drivers/xadow_LED_5x7.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera
18 | *
19 | */
20 |
21 | #include "frosted.h"
22 | #include "device.h"
23 | #include
24 | #include "cirbuf.h"
25 | #include "dma.h"
26 | #include "cirbuf.h"
27 | #include "i2c.h"
28 |
29 | #define XADOW_LED_I2C_ADDR (0x21 << 1)
30 |
31 | #define DISP_CHAR_5X7 0x80
32 | #define DISP_STRING 0x81
33 | #define SET_DISP_ORIENTATION 0x82
34 | #define POWER_DOWN 0x83
35 | #define DISP_PIC 0x84
36 | #define DISP_DATA 0x85
37 |
38 | struct dev_matrix {
39 | struct i2c_slave i2c;
40 | struct device *dev;
41 | uint8_t i2c_data;
42 | uint8_t buf[20];
43 | int update;
44 | } Matrix;
45 |
46 | static struct task *kt = NULL;
47 |
48 |
49 |
50 | /* Module description */
51 | static int xadow_led_read(struct fnode *fno, void *buf, unsigned int len)
52 | {
53 | return 0;
54 | }
55 |
56 |
57 | static int xadow_led_write(struct fnode *fno, const void *buf, unsigned int len)
58 | {
59 | memset(Matrix.buf, 0, 20);
60 | if (len > 17)
61 | len = 17;
62 | Matrix.buf[0] = len;
63 | if (len > 0) {
64 | memcpy(Matrix.buf + 1, buf, len);
65 | }
66 | Matrix.buf[len + 1] = 0;
67 | Matrix.buf[len + 2] = 120;
68 |
69 | Matrix.update = len + 3;
70 | return len;
71 | }
72 |
73 | static void xadow_led_task(void *arg)
74 | {
75 | (void)arg;
76 | int r;
77 | Matrix.update = 0;
78 | while(1<2) {
79 | if (Matrix.update) {
80 | r = i2c_kthread_write(&Matrix.i2c, DISP_STRING, Matrix.buf, Matrix.update);
81 | Matrix.update = 0;
82 | }
83 | kthread_yield();
84 | }
85 | }
86 |
87 | static int xadow_led_open(const char *path, int flags)
88 | {
89 | struct fnode *f = fno_search(path);
90 | if (!f)
91 | return -1;
92 | kt = kthread_create(xadow_led_task, NULL);
93 | return task_filedesc_add(f);
94 | }
95 |
96 | static int xadow_led_close(struct fnode *f)
97 | {
98 | if (kt) {
99 | kthread_cancel(kt);
100 | kt = NULL;
101 | }
102 | return 0;
103 | }
104 |
105 | static struct module mod_devmatrix = {
106 | .family = FAMILY_FILE,
107 | .name = "matrix",
108 | .ops.open = xadow_led_open,
109 | .ops.read = xadow_led_read,
110 | .ops.write = xadow_led_write,
111 | .ops.close = xadow_led_close
112 | };
113 |
114 |
115 | int xadow_led_init(uint32_t bus)
116 | {
117 | int i;
118 | struct fnode *devdir = fno_search("/dev");
119 | if (!devdir)
120 | return -ENOENT;
121 | memset(&Matrix, 0, sizeof(struct dev_matrix));
122 | Matrix.dev = device_fno_init(&mod_devmatrix, "matrix", devdir, 0, &Matrix);
123 |
124 |
125 | /* Populate i2c_slave struct */
126 | Matrix.i2c.bus = bus;
127 | Matrix.i2c.address = XADOW_LED_I2C_ADDR;
128 | //kthread_create(xadow_led_task, NULL);
129 | return 0;
130 | }
131 |
--------------------------------------------------------------------------------
/kernel/fonts/palette_256_xterm.c:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | const uint32_t xterm_cmap[256] = {
4 | 0x000000, 0x800000, 0x008000, 0x808000, 0x000080, 0x800080, 0x008080, 0xC0C0C0,
5 | 0x808080, 0xFF0000, 0x00FF00, 0xFFFF00, 0x0000FF, 0xFF00FF, 0x00FFFF, 0xFFFFFF,
6 | 0x000000, 0x00005F, 0x000087, 0x0000AF, 0x0000D7, 0x0000FF, 0x005F00, 0x005F5F,
7 | 0x005F87, 0x005FAF, 0x005FD7, 0x005FFF, 0x008700, 0x00875F, 0x008787, 0x0087AF,
8 | 0x0087D7, 0x0087FF, 0x00AF00, 0x00AF5F, 0x00AF87, 0x00AFAF, 0x00AFD7, 0x00AFFF,
9 | 0x00D700, 0x00D75F, 0x00D787, 0x00D7AF, 0x00D7D7, 0x00D7FF, 0x00FF00, 0x00FF5F,
10 | 0x00FF87, 0x00FFAF, 0x00FFD7, 0x00FFFF, 0x5F0000, 0x5F005F, 0x5F0087, 0x5F00AF,
11 | 0x5F00D7, 0x5F00FF, 0x5F5F00, 0x5F5F5F, 0x5F5F87, 0x5F5FAF, 0x5F5FD7, 0x5F5FFF,
12 | 0x5F8700, 0x5F875F, 0x5F8787, 0x5F87AF, 0x5F87D7, 0x5F87FF, 0x5FAF00, 0x5FAF5F,
13 | 0x5FAF87, 0x5FAFAF, 0x5FAFD7, 0x5FAFFF, 0x5FD700, 0x5FD75F, 0x5FD787, 0x5FD7AF,
14 | 0x5FD7D7, 0x5FD7FF, 0x5FFF00, 0x5FFF5F, 0x5FFF87, 0x5FFFAF, 0x5FFFD7, 0x5FFFFF,
15 | 0x870000, 0x87005F, 0x870087, 0x8700AF, 0x8700D7, 0x8700FF, 0x875F00, 0x875F5F,
16 | 0x875F87, 0x875FAF, 0x875FD7, 0x875FFF, 0x878700, 0x87875F, 0x878787, 0x8787AF,
17 | 0x8787D7, 0x8787FF, 0x87AF00, 0x87AF5F, 0x87AF87, 0x87AFAF, 0x87AFD7, 0x87AFFF,
18 | 0x87D700, 0x87D75F, 0x87D787, 0x87D7AF, 0x87D7D7, 0x87D7FF, 0x87FF00, 0x87FF5F,
19 | 0x87FF87, 0x87FFAF, 0x87FFD7, 0x87FFFF, 0xAF0000, 0xAF005F, 0xAF0087, 0xAF00AF,
20 | 0xAF00D7, 0xAF00FF, 0xAF5F00, 0xAF5F5F, 0xAF5F87, 0xAF5FAF, 0xAF5FD7, 0xAF5FFF,
21 | 0xAF8700, 0xAF875F, 0xAF8787, 0xAF87AF, 0xAF87D7, 0xAF87FF, 0xAFAF00, 0xAFAF5F,
22 | 0xAFAF87, 0xAFAFAF, 0xAFAFD7, 0xAFAFFF, 0xAFD700, 0xAFD75F, 0xAFD787, 0xAFD7AF,
23 | 0xAFD7D7, 0xAFD7FF, 0xAFFF00, 0xAFFF5F, 0xAFFF87, 0xAFFFAF, 0xAFFFD7, 0xAFFFFF,
24 | 0xD70000, 0xD7005F, 0xD70087, 0xD700AF, 0xD700D7, 0xD700FF, 0xD75F00, 0xD75F5F,
25 | 0xD75F87, 0xD75FAF, 0xD75FD7, 0xD75FFF, 0xD78700, 0xD7875F, 0xD78787, 0xD787AF,
26 | 0xD787D7, 0xD787FF, 0xD7AF00, 0xD7AF5F, 0xD7AF87, 0xD7AFAF, 0xD7AFD7, 0xD7AFFF,
27 | 0xD7D700, 0xD7D75F, 0xD7D787, 0xD7D7AF, 0xD7D7D7, 0xD7D7FF, 0xD7FF00, 0xD7FF5F,
28 | 0xD7FF87, 0xD7FFAF, 0xD7FFD7, 0xD7FFFF, 0xFF0000, 0xFF005F, 0xFF0087, 0xFF00AF,
29 | 0xFF00D7, 0xFF00FF, 0xFF5F00, 0xFF5F5F, 0xFF5F87, 0xFF5FAF, 0xFF5FD7, 0xFF5FFF,
30 | 0xFF8700, 0xFF875F, 0xFF8787, 0xFF87AF, 0xFF87D7, 0xFF87FF, 0xFFAF00, 0xFFAF5F,
31 | 0xFFAF87, 0xFFAFAF, 0xFFAFD7, 0xFFAFFF, 0xFFD700, 0xFFD75F, 0xFFD787, 0xFFD7AF,
32 | 0xFFD7D7, 0xFFD7FF, 0xFFFF00, 0xFFFF5F, 0xFFFF87, 0xFFFFAF, 0xFFFFD7, 0xFFFFFF,
33 | 0x080808, 0x121212, 0x1C1C1C, 0x262626, 0x303030, 0x3A3A3A, 0x444444, 0x4E4E4E,
34 | 0x585858, 0x626262, 0x6C6C6C, 0x767676, 0x808080, 0x8A8A8A, 0x949494, 0x9E9E9E,
35 | 0xA8A8A8, 0xB2B2B2, 0xBCBCBC, 0xC6C6C6, 0xD0D0D0, 0xDADADA, 0xE4E4E4, 0xEEEEEE
36 | };
37 |
--------------------------------------------------------------------------------
/kernel/fortuna.h:
--------------------------------------------------------------------------------
1 | #ifndef FORTUNA_H_
2 | #define FORTUNA_H_
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | /* Defines for hash and encryption algorithms */
9 | #define FORTUNA_HASH_SIZE 32
10 | #define FORTUNA_ENCRYPT_IV_SIZE 16
11 | #define FORTUNA_ENCRYPT_KEY_SIZE 32
12 | #define FORTUNA_ENCRYPT_BLOCK_SIZE 16
13 |
14 | int fortuna_init(void);
15 | void fortuna_accu(int source, int pool, uint8_t *data, int data_size);
16 |
17 | /* Get random stuff! */
18 | int fortuna_get_bytes(uint8_t *buffer, int count);
19 |
20 | /* Shut down the generator securely if it is no longer needed */
21 | void fortuna_shutdown(void);
22 |
23 | #endif /* FORTUNA_H_ */
24 |
25 |
--------------------------------------------------------------------------------
/kernel/fpb.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera
18 | *
19 | */
20 |
21 |
22 | #include "fpb.h"
23 | #include
24 |
25 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
26 | #define FPB_NUM_CODE2_OFF 12
27 | #define FPB_NUM_LIT_MASK_OFF 8
28 | #define FPB_NUM_CODE1_OFF 4
29 |
30 |
31 | #define DBG_DHCSR MMIO32(0xE000EDF0)
32 | #define DBG_DEMCR MMIO32(0xE000EDFC)
33 |
34 | #define DBG_DHCSR_KEY ((0xA0 << 24) | (0x5F << 16))
35 | #define DBG_DHCSR_HALT (1 << 1)
36 | #define DBG_DHCSR_STEP (1 << 2)
37 |
38 |
39 | #define DBG_DEMCR_MON_STEP (1 << 18)
40 | #define DBG_DEMCR_MON_PEND (1 << 17)
41 | #define DBG_DEMCR_MON_EN (1 << 16)
42 |
43 | #define FPB_REPLACE_LO (1 << 30)
44 | #define FPB_REPLACE_HI (2 << 30)
45 | #define FPB_REPLACE_BOTH (3 << 30)
46 |
47 |
48 | struct bkpt {
49 | int pid;
50 | void *b;
51 | };
52 |
53 | struct bkpt bkpt[8];
54 |
55 | void debug_monitor_handler(void)
56 | {
57 | int pid;
58 | kprintf("TRAP!\r\n");
59 | /* Exit debug state */
60 | task_hit_breakpoint(this_task());
61 | DBG_DHCSR = DBG_DHCSR_KEY;
62 | }
63 |
64 | int fpb_setbrk(int pid, void *bpoint, int n)
65 | {
66 | int i;
67 | if (n < 0) {
68 | for (i = 0; i < 8; i++) {
69 | if (bkpt[i].pid == 0) {
70 | n = i;
71 | break;
72 | }
73 | }
74 | }
75 | if (n < 0)
76 | return -1;
77 | bkpt[n].pid = pid;
78 | bkpt[n].b = bpoint;
79 | if ((uint32_t)bpoint & 0x01)
80 | return -1;
81 | if ((uint32_t)bpoint & 0x02)
82 | FPB_COMP[n] = FPB_COMP_ENABLE | (((uint32_t)bpoint) & (0x1FFFFFFC)) | FPB_REPLACE_HI;
83 | else
84 | FPB_COMP[n] = FPB_COMP_ENABLE | (((uint32_t)bpoint) & (0x1FFFFFFC)) | FPB_REPLACE_LO;
85 | return n;
86 | }
87 |
88 | int fpb_delbrk(int n)
89 | {
90 | bkpt[n].pid = 0;
91 | FPB_COMP[n] = 0;
92 | }
93 |
94 |
95 | int fpb_init(void)
96 | {
97 | if (FPB_CTRL == 0x0) {
98 | return -1;
99 | }
100 | if (FPB_COMP[0] == 0x0) {
101 | return -1;
102 | }
103 | /* Enable Debug Monitor Exception */
104 | DBG_DEMCR = DBG_DEMCR_MON_EN;
105 | FPB_CTRL = FPB_CTRL_ENABLE | FPB_CTRL_KEY | (1 << FPB_NUM_CODE2_OFF) | (2 << FPB_NUM_LIT_MASK_OFF);
106 | nvic_enable_irq(DEBUG_MONITOR_IRQ);
107 | }
108 |
109 | #endif
110 |
--------------------------------------------------------------------------------
/kernel/fpb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera
18 | *
19 | */
20 |
21 | #ifndef FROSTED_FPB_INC
22 | #define FROSTED_FPB_INC
23 |
24 | #include "frosted.h"
25 | /* Those defined only on ARMv7 and above */
26 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
27 | #include
28 |
29 | int fpb_init(void);
30 | int fpb_setbrk(int pid, void *bpoint, int n);
31 | int fpb_delbrk(int n);
32 |
33 | #endif
34 | #endif
35 |
--------------------------------------------------------------------------------
/kernel/frand.h:
--------------------------------------------------------------------------------
1 | #ifndef FRAND_H_
2 | #define FRAND_H_
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | #include "frosted.h"
9 |
10 | struct frand_ops;
11 |
12 | struct frand_info {
13 | struct frand_ops *frandops;
14 | struct device *dev; /* This is this frand device */
15 | };
16 |
17 | struct frand_ops {
18 | /* open/release and usage marking */
19 | int (*frand_open)(struct frand_info *info);
20 | };
21 |
22 | /* For setting up the generator and feeding entropy */
23 | /* low-level drivers must call this register function first */
24 | int register_frand(struct frand_info *frand_info);
25 |
26 | /* kernel init */
27 | void frand_init(struct fnode *dev);
28 |
29 | #endif /* FRAND_H_ */
30 |
31 |
--------------------------------------------------------------------------------
/kernel/fs/fatfs.h:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 |
3 | #ifndef FATFS_INC
4 | #define FATFS_INC
5 |
6 |
7 | #ifdef CONFIG_FATFS
8 |
9 | int fatfs_init(void);
10 |
11 | #else
12 | #define fatfs_init() ((-ENOENT))
13 |
14 | #endif
15 |
16 |
17 | #endif
18 |
--------------------------------------------------------------------------------
/kernel/fs/xipfs.h:
--------------------------------------------------------------------------------
1 | #ifndef XIPFS_INCLUDED
2 | #define XIPFS_INCLUDED
3 | #define XIPFS_MAGIC 0xC519FF55
4 |
5 | #include
6 |
7 | struct xipfs_fat {
8 | uint32_t fs_magic;
9 | uint32_t fs_size;
10 | uint32_t fs_files;
11 | uint32_t timestamp;
12 | };
13 |
14 | struct xipfs_fhdr {
15 | uint32_t magic;
16 | char name[56];
17 | uint32_t len;
18 | uint8_t payload[0];
19 | };
20 |
21 | void xipfs_init(void);
22 | #endif
23 |
--------------------------------------------------------------------------------
/kernel/hardfault_debug.c:
--------------------------------------------------------------------------------
1 | /**
2 | * HardFault_HandlerAsm:
3 | * Alternative Hard Fault handler to help debug the reason for a fault.
4 | * To use, edit the vector table to reference this function in the HardFault vector
5 | * This code is suitable for Cortex-M3 and Cortex-M0 cores
6 | */
7 |
8 | void HardFault_HandlerC(unsigned long *hardfault_args);
9 |
10 | // Use the 'naked' attribute so that C stacking is not used.
11 | __attribute__((naked))
12 | void HardFault_Handler(void)
13 | {
14 | /*
15 | * Get the appropriate stack pointer, depending on our mode,
16 | * and use it as the parameter to the C handler. This function
17 | * will never return
18 | */
19 | __asm("TST LR, #4 \n"
20 | "ITE EQ \n"
21 | "MRSEQ R0, MSP \n"
22 | "MRSNE R0, PSP \n"
23 | "B HardFault_HandlerC \n"
24 | );
25 | }
26 |
27 | // Use the 'naked' attribute so that C stacking is not used.
28 | __attribute__((naked))
29 | void UsageFault_Handler(void)
30 | {
31 | /*
32 | * Get the appropriate stack pointer, depending on our mode,
33 | * and use it as the parameter to the C handler. This function
34 | * will never return
35 | */
36 | __asm("TST LR, #4 \n"
37 | "ITE EQ \n"
38 | "MRSEQ R0, MSP \n"
39 | "MRSNE R0, PSP \n"
40 | "B HardFault_HandlerC \n"
41 | );
42 | }
43 |
44 | /**
45 | * HardFaultHandler_C:
46 | * This is called from the HardFault_HandlerAsm with a pointer the Fault stack
47 | * as the parameter. We can then read the values from the stack and place them
48 | * into local variables for ease of reading.
49 | * We then read the various Fault Status and Address Registers to help decode
50 | * cause of the fault.
51 | * The function ends with a BKPT instruction to force control back into the debugger
52 | */
53 | volatile unsigned long stacked_r0 ;
54 | volatile unsigned long stacked_r1 ;
55 | volatile unsigned long stacked_r2 ;
56 | volatile unsigned long stacked_r3 ;
57 | volatile unsigned long stacked_r12 ;
58 | volatile unsigned long stacked_lr ;
59 | volatile unsigned long stacked_pc ;
60 | volatile unsigned long stacked_psr ;
61 | volatile unsigned long _CFSR ;
62 | volatile unsigned long _HFSR ;
63 | volatile unsigned long _DFSR ;
64 | volatile unsigned long _AFSR ;
65 | volatile unsigned long _BFAR ;
66 | volatile unsigned long _MMAR ;
67 |
68 | void HardFault_HandlerC(unsigned long *hardfault_args){
69 | stacked_r0 = ((unsigned long)hardfault_args[0]) ;
70 | stacked_r1 = ((unsigned long)hardfault_args[1]) ;
71 | stacked_r2 = ((unsigned long)hardfault_args[2]) ;
72 | stacked_r3 = ((unsigned long)hardfault_args[3]) ;
73 | stacked_r12 = ((unsigned long)hardfault_args[4]) ;
74 | stacked_lr = ((unsigned long)hardfault_args[5]) ;
75 | stacked_pc = ((unsigned long)hardfault_args[6]) ;
76 | stacked_psr = ((unsigned long)hardfault_args[7]) ;
77 |
78 | // Configurable Fault Status Register
79 | // Consists of MMSR, BFSR and UFSR
80 | _CFSR = (*((volatile unsigned long *)(0xE000ED28))) ;
81 |
82 | // Hard Fault Status Register
83 | _HFSR = (*((volatile unsigned long *)(0xE000ED2C))) ;
84 |
85 | // Debug Fault Status Register
86 | _DFSR = (*((volatile unsigned long *)(0xE000ED30))) ;
87 |
88 | // Auxiliary Fault Status Register
89 | _AFSR = (*((volatile unsigned long *)(0xE000ED3C))) ;
90 |
91 | // Read the Fault Address Registers. These may not contain valid values.
92 | // Check BFARVALID/MMARVALID to see if they are valid values
93 | // MemManage Fault Address Register
94 | _MMAR = (*((volatile unsigned long *)(0xE000ED34))) ;
95 | // Bus Fault Address Register
96 | _BFAR = (*((volatile unsigned long *)(0xE000ED38))) ;
97 |
98 | __asm("BKPT #0") ; // Break into the debugger
99 |
100 | }
101 |
102 |
--------------------------------------------------------------------------------
/kernel/interrupts.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef FROSTED_INTERRUPTS_H
3 | #define FROSTED_INTERRUPTS_H
4 |
5 | extern void __set_BASEPRI(int);
6 |
7 | #ifdef DEBUG
8 | static void irq_off(void)
9 | {
10 | }
11 |
12 | static void irq_on(void)
13 | {
14 | }
15 |
16 | static void irq_setmask(void)
17 | {
18 | }
19 |
20 | static void irq_clearmask(void)
21 | {
22 | }
23 | #else
24 | /* Inline kernel utils */
25 |
26 | static inline void irq_setmask(void)
27 | {
28 | __set_BASEPRI(3);
29 | }
30 |
31 | static inline void irq_clearmask(void)
32 | {
33 | __set_BASEPRI(0u);
34 | }
35 |
36 | static inline void irq_off(void)
37 | {
38 | asm volatile ("cpsid i \n");
39 | }
40 |
41 | static inline void irq_on(void)
42 | {
43 | asm volatile ("cpsie i \n");
44 | }
45 | #endif
46 |
47 | #endif /* FROSTED_INTERRUPTS_H */
48 |
--------------------------------------------------------------------------------
/kernel/kprintf.h:
--------------------------------------------------------------------------------
1 | #ifndef KPRINTF_H
2 | #define KPRINTF_H
3 |
4 | #ifdef CONFIG_KLOG
5 | int klog_init(void);
6 | int ksprintf(char *out, const char *format, ...);
7 | int kprintf(const char *format, ...);
8 | #else
9 | # define klog_init() (0)
10 | # define kprintf
11 | #endif
12 |
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/kernel/lm3s/Kconfig:
--------------------------------------------------------------------------------
1 | if ARCH_LM3S
2 |
3 | choice
4 | prompt "MCU"
5 | default LM3S6965
6 | config ARCH_LM3S6965
7 | bool "LM3S6965"
8 | select FLASH_SIZE_256KB
9 | select RAM_SIZE_64KB
10 | config ARCH_LM3SVIRT
11 | bool "LM3S-VIRTUAL"
12 | select FLASH_SIZE_1MB
13 | select RAM_SIZE_256KB
14 | endchoice
15 |
16 | endif
17 |
--------------------------------------------------------------------------------
/kernel/lm3s/lm3s.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/insane-adding-machines/frosted/5c3aa21f146a1b840badfd72d1d8b96e8405a8d8/kernel/lm3s/lm3s.c
--------------------------------------------------------------------------------
/kernel/lm3s/lm3s.ld.in:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | *
3 | * standalone.ld - Linker script for applications using startup.c
4 | *
5 | *****************************************************************************/
6 | ENTRY(reset_handler)
7 | MEMORY
8 | {
9 | FLASH (rx) : ORIGIN = __FLASH_ORIGIN, LENGTH = __KFLASHMEM_SIZE
10 | SRAM (rwx) : ORIGIN = __RAM1_BASE, LENGTH = __KRAMMEM_SIZE
11 | SRAM_USER (rwx) : ORIGIN = (__RAM1_BASE + __KRAMMEM_SIZE), LENGTH = (__RAM1_SIZE - __KRAMMEM_SIZE)
12 | }
13 |
14 | __StackTop = ORIGIN(SRAM) + LENGTH(SRAM) - 4;
15 |
16 | SECTIONS
17 | {
18 | .text :
19 | {
20 | KEEP(*(.vectors))
21 | *(.text*)
22 | *(.rodata*)
23 | } > FLASH
24 | /* C++ Static constructors/destructors, also used for __attribute__
25 | * ((constructor)) and the likes */
26 | .preinit_array : {
27 | . = ALIGN(4);
28 | __preinit_array_start = .;
29 | KEEP (*(.preinit_array))
30 | __preinit_array_end = .;
31 | } > FLASH
32 | .init_array : {
33 | . = ALIGN(4);
34 | __init_array_start = .;
35 | KEEP (*(SORT(.init_array.*)))
36 | KEEP (*(.init_array))
37 | __init_array_end = .;
38 | } > FLASH
39 | .fini_array : {
40 | . = ALIGN(4);
41 | __fini_array_start = .;
42 | KEEP (*(.fini_array))
43 | KEEP (*(SORT(.fini_array.*)))
44 | __fini_array_end = .;
45 | } > FLASH
46 |
47 | .data :
48 | {
49 | _etext = LOADADDR(.data);
50 | _data = .;
51 | *(vtable)
52 | *(.data*)
53 | _edata = .;
54 | } > SRAM AT > FLASH
55 | _data_loadaddr = LOADADDR(.data);
56 |
57 | .bss :
58 | {
59 | _bss = .;
60 | *(.bss*)
61 | *(COMMON)
62 | . = ALIGN(32 / 8);
63 | _ebss = .;
64 | PROVIDE (end = .);
65 | } > SRAM
66 |
67 | .heap :
68 | {
69 | /* heap starts after BSS */
70 | PROVIDE(_heap_start = _ebss );
71 | } > SRAM
72 | }
73 |
74 | PROVIDE(_stack = ORIGIN(SRAM) + LENGTH(SRAM));
75 | PROVIDE(_user_heap_start = ORIGIN(SRAM_USER));
76 | PROVIDE(_user_heap_end = ORIGIN(SRAM_USER) + LENGTH(SRAM_USER));
77 |
78 |
--------------------------------------------------------------------------------
/kernel/lm3s/lm3s6965evb.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera, Maxime Vincent
18 | *
19 | */
20 | #include "frosted.h"
21 | #include "unicore-mx/lm3s/usart.h"
22 | #include "unicore-mx/lm3s/nvic.h"
23 | #include "eth.h"
24 |
25 | #ifdef CONFIG_DEVUART
26 | #include "uart.h"
27 | #endif
28 |
29 | /* TODO: Move to unicore-mx when implemented */
30 | int exti_init(void)
31 | {
32 | return 0;
33 | }
34 |
35 | int exti_enable(void)
36 | {
37 | return 0;
38 | }
39 |
40 | int exti_register(void)
41 | {
42 | return 0;
43 | }
44 |
45 | int gpio_init(void)
46 | {
47 | return 0;
48 | }
49 |
50 | int gpio_create(struct module *mod, const struct gpio_config *gpio_config)
51 | {
52 | return 0;
53 | }
54 |
55 |
56 | void usart_set_baudrate(uint32_t usart, uint32_t baud)
57 | {
58 | /* TODO */
59 | (void)usart;
60 | (void)baud;
61 | }
62 |
63 | void usart_set_databits(uint32_t usart, int bits)
64 | {
65 | /* TODO */
66 | (void)usart;
67 | (void)bits;
68 | }
69 |
70 | void usart_set_stopbits(uint32_t usart, enum usart_stopbits sb)
71 | {
72 | /* TODO */
73 | (void)usart;
74 | (void)sb;
75 | }
76 |
77 | void usart_set_parity(uint32_t usart, enum usart_parity par)
78 | {
79 | /* TODO */
80 | (void)usart;
81 | (void)par;
82 | }
83 |
84 | void usart_set_mode(uint32_t usart, enum usart_mode mode)
85 | {
86 | /* TODO */
87 | (void)usart;
88 | (void)mode;
89 | }
90 |
91 | void usart_set_flow_control(uint32_t usart, enum usart_flowcontrol fc)
92 | {
93 | /* TODO */
94 | (void)usart;
95 | (void)fc;
96 | }
97 |
98 | void usart_enable(uint32_t usart)
99 | {
100 | (void)usart;
101 | }
102 |
103 | void usart_disable(uint32_t usart)
104 | {
105 | (void)usart;
106 | }
107 |
108 |
109 |
110 | static const struct uart_config uart_configs[] = {
111 | #ifdef CONFIG_USART_0
112 | {
113 | .base = USART0_BASE,
114 | .irq = NVIC_UART0_IRQ,
115 | },
116 | #endif
117 | #ifdef CONFIG_USART_1
118 | {
119 | .base = USART1_BASE,
120 | .irq = NVIC_UART1_IRQ,
121 | },
122 | #endif
123 | #ifdef CONFIG_USART_2
124 | {
125 | .base = USART2_BASE,
126 | .irq = NVIC_UART2_IRQ,
127 | },
128 | #endif
129 | };
130 |
131 | #define NUM_UARTS (sizeof(uart_configs) / sizeof(struct uart_config))
132 |
133 |
134 | int machine_init(void)
135 | {
136 | int i;
137 | rcc_clock_setup_in_xtal_8mhz_out_50mhz();
138 |
139 | for (i = 0; i < NUM_UARTS; i++)
140 | uart_create(&(uart_configs[i]));
141 |
142 | ethernet_init(NULL);
143 |
144 | return 0;
145 | }
146 |
147 |
148 |
--------------------------------------------------------------------------------
/kernel/locks.h:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 | /* Structures */
3 | struct semaphore {
4 | int value;
5 | uint32_t signature;
6 | int listeners;
7 | int last;
8 | struct task **listener;
9 | };
10 |
11 |
12 | int suspend_on_sem_wait(sem_t *s);
13 | int suspend_on_mutex_lock(mutex_t *s);
14 |
--------------------------------------------------------------------------------
/kernel/lowpower.h:
--------------------------------------------------------------------------------
1 | #ifndef LOWPOWER_H_INC
2 | #define LOWPOWER_H_INC
3 | #include
4 |
5 | #ifndef CONFIG_LOWPOWER
6 | # define lowpower_init() (-1)
7 | # define lowpower_sleep(x,y) (-1)
8 | #else
9 | int lowpower_init(void);
10 | int lowpower_sleep(int stdby, uint32_t interval);
11 | #endif
12 | #endif
13 |
--------------------------------------------------------------------------------
/kernel/lpc17xx.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_LPC17CC
2 | #define INC_LPC17CC
3 |
4 | #ifdef CONFIG_DEVUART
5 | #include "uart.h"
6 | #endif
7 |
8 | #ifdef CONFIG_DEVUART
9 | void uart_init(struct fnode * dev, const struct uart_addr uart_addrs[], int num_uarts);
10 | #endif
11 |
12 | #endif
13 |
--------------------------------------------------------------------------------
/kernel/lpc17xx/Kconfig:
--------------------------------------------------------------------------------
1 | if ARCH_LPC17XX
2 |
3 | choice
4 | prompt "MCU"
5 | default ARCH_LPC1768
6 | config ARCH_LPC1763
7 | bool "LPC1763"
8 | select FLASH_SIZE_256KB
9 | select RAM_SIZE_32KB
10 | select CLK_100MHZ
11 | config ARCH_LPC1764
12 | bool "LPC1764"
13 | select FLASH_SIZE_128KB
14 | select RAM_SIZE_16KB
15 | select CLK_100MHZ
16 | config ARCH_LPC1765
17 | bool "LPC1765"
18 | select FLASH_SIZE_256KB
19 | select RAM_SIZE_32KB
20 | select CLK_100MHZ
21 | config ARCH_LPC1766
22 | bool "LPC1766"
23 | select FLASH_SIZE_256KB
24 | select RAM_SIZE_32KB
25 | select CLK_100MHZ
26 | config ARCH_LPC1767
27 | bool "LPC1767"
28 | select FLASH_SIZE_512KB
29 | select RAM_SIZE_32KB
30 | select CLK_100MHZ
31 | config ARCH_LPC1768
32 | bool "LPC1768"
33 | select FLASH_SIZE_512KB
34 | select RAM_SIZE_32KB
35 | select CLK_100MHZ
36 | config ARCH_LPC1769
37 | bool "LPC1769"
38 | select FLASH_SIZE_512KB
39 | select RAM_SIZE_32KB
40 | endchoice
41 |
42 | endif
43 |
--------------------------------------------------------------------------------
/kernel/lpc17xx/lpc17xx.ld.in:
--------------------------------------------------------------------------------
1 | MEMORY
2 | {
3 | FLASH (rx) : ORIGIN = __FLASH_ORIGIN, LENGTH = __KFLASHMEM_SIZE
4 | SRAM (rwx) : ORIGIN = __RAM1_BASE, LENGTH = __KRAMMEM_SIZE
5 | SRAM_USER (rwx) : ORIGIN = __RAM2_BASE, LENGTH = __RAM2_SIZE
6 | SRAM_EXTRA(rwx) : ORIGIN = __RAM3_BASE, LENGTH = __RAM3_SIZE
7 | }
8 |
9 | /* Enforce emmition of the vector table. */
10 | EXTERN (vector_table)
11 |
12 | /* Define the entry point of the output file. */
13 | ENTRY(reset_handler)
14 |
15 | SECTIONS
16 | {
17 | .text :
18 | {
19 | KEEP(*(.vectors))
20 | *(.text*)
21 | *(.rodata*)
22 | } > FLASH
23 | /* C++ Static constructors/destructors, also used for __attribute__
24 | * ((constructor)) and the likes */
25 | .preinit_array : {
26 | . = ALIGN(4);
27 | __preinit_array_start = .;
28 | KEEP (*(.preinit_array))
29 | __preinit_array_end = .;
30 | } > FLASH
31 | .init_array : {
32 | . = ALIGN(4);
33 | __init_array_start = .;
34 | KEEP (*(SORT(.init_array.*)))
35 | KEEP (*(.init_array))
36 | __init_array_end = .;
37 | } > FLASH
38 | .fini_array : {
39 | . = ALIGN(4);
40 | __fini_array_start = .;
41 | KEEP (*(.fini_array))
42 | KEEP (*(SORT(.fini_array.*)))
43 | __fini_array_end = .;
44 | } > FLASH
45 |
46 | .data :
47 | {
48 | _etext = LOADADDR(.data);
49 | _data = .;
50 | *(vtable)
51 | *(.data*)
52 | _edata = .;
53 | } > SRAM AT > FLASH
54 | _data_loadaddr = LOADADDR(.data);
55 |
56 | .bss :
57 | {
58 | _bss = .;
59 | *(.bss*)
60 | *(COMMON)
61 | . = ALIGN(32 / 8);
62 | _ebss = .;
63 | PROVIDE (end = .);
64 | } > SRAM
65 |
66 | .heap :
67 | {
68 | /* heap starts after BSS */
69 | PROVIDE(_heap_start = _ebss );
70 | } > SRAM
71 | }
72 |
73 | PROVIDE(_stack = ORIGIN(SRAM) + LENGTH(SRAM));
74 | PROVIDE(_user_heap_start = ORIGIN(SRAM_USER));
75 | PROVIDE(_user_heap_end = ORIGIN(SRAM_USER) + LENGTH(SRAM_USER));
76 | PROVIDE(_extra_heap_start = ORIGIN(SRAM_EXTRA));
77 | PROVIDE(_extra_heap_end = ORIGIN(SRAM_EXTRA) + LENGTH(SRAM_EXTRA));
78 |
79 |
--------------------------------------------------------------------------------
/kernel/malloc.h:
--------------------------------------------------------------------------------
1 | #ifndef _FROSTED_MALLOC_H
2 | #define _FROSTED_MALLOC_H
3 |
4 | #include "string.h"
5 | #include "stdint.h"
6 |
7 | #define MEM_KERNEL 0
8 | #define MEM_USER 1
9 | #define MEM_TASK 2
10 | #define MEM_EXTRA 9
11 |
12 | #ifdef CONFIG_TCPIP_MEMPOOL
13 | # define MEM_TCPIP 4
14 | # define MEM_OWNER_MASK 7
15 | #else
16 | # define MEM_TCPIP MEM_KERNEL
17 | # define MEM_OWNER_MASK 3
18 | #endif
19 |
20 |
21 |
22 | struct f_malloc_stats {
23 | uint32_t malloc_calls;
24 | uint32_t free_calls;
25 | uint32_t objects_allocated;
26 | uint32_t mem_allocated;
27 | };
28 |
29 | void * u_malloc(size_t size);
30 | void * f_malloc(int flags, size_t size);
31 | void * f_calloc(int flags, size_t num, size_t size);
32 | void* f_realloc(int flags, void* ptr, size_t size);
33 | void f_free(void * ptr);
34 |
35 | /* Free up heap of a specific pid */
36 | void f_proc_heap_free(int pid);
37 |
38 | /* Get heap usage for specific pid */
39 | uint32_t f_proc_heap_count(int pid);
40 |
41 | #endif /* _FROSTED_MALLOC_H */
42 |
--------------------------------------------------------------------------------
/kernel/mpu.h:
--------------------------------------------------------------------------------
1 | #ifndef FROSTED_MPU_H
2 | #define FROSTED_MPU_H
3 |
4 | #ifdef CONFIG_MPU
5 | void mpu_init(void);
6 | void mpu_task_on(void *stack);
7 | #else
8 | # define mpu_init() do{}while(0)
9 | # define mpu_task_on(x) do{}while(0)
10 | #endif
11 |
12 |
13 |
14 |
15 | #endif
16 |
17 |
--------------------------------------------------------------------------------
/kernel/mutex.S:
--------------------------------------------------------------------------------
1 |
2 | .syntax unified
3 |
4 | /* Lock function.
5 | * On success, return 0.
6 | * On failure, return -1 (Locked, try again later).
7 | */
8 |
9 | .global _mutex_lock
10 | _mutex_lock:
11 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
12 | LDREX r1, [r0]
13 | #elif defined(__ARCH_V6M__)
14 | CPSID i
15 | LDR r1, [r0]
16 | #endif
17 | CMP r1, #0 // Test if mutex holds the value 0
18 | BEQ _mutex_lock_fail // If it does, return 0
19 | SUBS r1, #1 // If not, decrement temporary copy
20 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
21 | STREX r2, r1, [r0] // Attempt Store-Exclusive
22 | CMP r2, #0 // Check if Store-Exclusive succeeded
23 | BNE _mutex_lock // If Store-Exclusive failed, retry from start
24 | DMB // Required before accessing protected resource
25 | #elif defined(__ARM_ARCH_6M__)
26 | STR r1, [r0]
27 | CPSIE i
28 | #endif
29 | MOVS r0, #0 // Successfully locked.
30 | BX lr
31 | _mutex_lock_fail:
32 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
33 | DMB
34 | MOV r0, #-1 // Already locked!
35 | #elif defined(__ARM_ARCH_6M__)
36 | CPSIE i
37 | MOVS r2, #0 // Already locked!
38 | MVNS r0, r2
39 | #endif
40 | BX lr
41 |
42 | /* Unlock mutex.
43 | * On success, return 0.
44 | * On failure, return -1 (Already unlocked!).
45 | */
46 |
47 | .global _mutex_unlock
48 | _mutex_unlock:
49 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
50 | LDREX r1, [r0]
51 | #elif defined(__ARM_ARCH_6M__)
52 | CPSID i
53 | LDR r1, [r0]
54 | #endif
55 | CMP r1, #0 // Test if mutex holds the value 0
56 | BNE _mutex_unlock_fail // If it does not, it's already locked!
57 | ADDS r1, #1 // Increment temporary copy
58 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
59 | STREX r2, r1, [r0] // Attempt Store-Exclusive
60 | CMP r2, #0 // Check if Store-Exclusive succeeded
61 | BNE _mutex_unlock // Store failed - retry immediately
62 | DMB // Required before releasing protected resource
63 | #elif defined(__ARM_ARCH_6M__)
64 | STR r1, [r0]
65 | CPSIE i
66 | #endif
67 | MOVS r0, #0 // Successfully unlocked.
68 | BX lr
69 | _mutex_unlock_fail:
70 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
71 | DMB
72 | MOV r0, #-1 // Already locked!
73 | #elif defined(__ARM_ARCH_6M__)
74 | CPSIE i
75 | MOVS r2, #0 // Already locked!
76 | MVNS r0, r2
77 | #endif
78 | BX lr
79 |
80 |
--------------------------------------------------------------------------------
/kernel/net/Kconfig:
--------------------------------------------------------------------------------
1 | if PICOTCP
2 |
3 | menu "picoTCP configuration"
4 |
5 | config CONFIG_PICOTCP_IPV4
6 | bool "Support for IP version 4"
7 | default y
8 |
9 | config CONFIG_PICOTCP_IPV6
10 | bool "Support for IP version 6"
11 | default n
12 |
13 | config CONFIG_PICOTCP_TCP
14 | bool "Support for TCP"
15 | default y
16 |
17 | config CONFIG_PICOTCP_UDP
18 | bool "Support for UDP"
19 | default y
20 |
21 | config CONFIG_PICOTCP_DNS
22 | bool "Support for DNS client"
23 | default y
24 |
25 | config CONFIG_PICOTCP_MCAST
26 | bool "Support for Multicast"
27 | default n
28 |
29 | config CONFIG_PICOTCP_NAT
30 | bool "Support for NAT"
31 | default n
32 |
33 | config CONFIG_PICOTCP_IPFILTER
34 | bool "Support for IP Filter"
35 | default n
36 |
37 | config CONFIG_PICOTCP_LOOP
38 | bool "Support for loopback device"
39 | default y
40 |
41 | config CONFIG_PICOTCP_DEBUG
42 | bool "Activate debugging symbols"
43 | default n
44 |
45 | endmenu
46 | endif
47 |
--------------------------------------------------------------------------------
/kernel/net/pico_lock.c:
--------------------------------------------------------------------------------
1 | #include "frosted.h"
2 | #include "locks.h"
3 |
4 | static mutex_t *picotcp_lock = NULL;
5 | void pico_lock_init(void)
6 | {
7 | if (!picotcp_lock)
8 | picotcp_lock = mutex_init();
9 | }
10 |
11 | void pico_lock(void)
12 | {
13 | if (picotcp_lock)
14 | mutex_lock(picotcp_lock);
15 | }
16 |
17 | int pico_trylock(void)
18 | {
19 | if(picotcp_lock)
20 | return suspend_on_mutex_lock(picotcp_lock);
21 | else
22 | return 0;
23 | }
24 |
25 | int pico_trylock_kernel(void)
26 | {
27 | if (!picotcp_lock)
28 | return -EAGAIN;
29 | return mutex_trylock(picotcp_lock);
30 | }
31 |
32 | void pico_unlock(void)
33 | {
34 | if (picotcp_lock) {
35 | mutex_unlock(picotcp_lock);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/kernel/net/route.h:
--------------------------------------------------------------------------------
1 | #ifndef NET_ROUTE_H
2 | #define NET_ROUTE_H
3 | #include
4 | #include
5 |
6 |
7 | struct rtentry {
8 | unsigned long int rt_pad1;
9 | struct sockaddr rt_dst;
10 | struct sockaddr rt_gateway;
11 | struct sockaddr rt_genmask;
12 | unsigned short int rt_flags;
13 | short int rt_pad2;
14 | unsigned long int rt_pad3;
15 | unsigned char rt_tos;
16 | unsigned char rt_class;
17 | short int rt_pad4[sizeof(long)/2-1];
18 | short int rt_metric;
19 | char *rt_dev;
20 | unsigned long int rt_mtu;
21 | unsigned long int rt_window;
22 | unsigned short int rt_irtt;
23 | };
24 |
25 | #define rt_mss rt_mtu
26 |
27 |
28 | struct in6_rtmsg {
29 | struct in6_addr rtmsg_dst;
30 | struct in6_addr rtmsg_src;
31 | struct in6_addr rtmsg_gateway;
32 | uint32_t rtmsg_type;
33 | uint16_t rtmsg_dst_len;
34 | uint16_t rtmsg_src_len;
35 | uint32_t rtmsg_metric;
36 | unsigned long int rtmsg_info;
37 | uint32_t rtmsg_flags;
38 | int rtmsg_ifindex;
39 | };
40 |
41 |
42 | #define RTF_UP 0x0001
43 | #define RTF_GATEWAY 0x0002
44 |
45 | #define RTF_HOST 0x0004
46 | #define RTF_REINSTATE 0x0008
47 | #define RTF_DYNAMIC 0x0010
48 | #define RTF_MODIFIED 0x0020
49 | #define RTF_MTU 0x0040
50 | #define RTF_MSS RTF_MTU
51 | #define RTF_WINDOW 0x0080
52 | #define RTF_IRTT 0x0100
53 | #define RTF_REJECT 0x0200
54 | #define RTF_STATIC 0x0400
55 | #define RTF_XRESOLVE 0x0800
56 | #define RTF_NOFORWARD 0x1000
57 | #define RTF_THROW 0x2000
58 | #define RTF_NOPMTUDISC 0x4000
59 |
60 | #define RTF_DEFAULT 0x00010000
61 | #define RTF_ALLONLINK 0x00020000
62 | #define RTF_ADDRCONF 0x00040000
63 |
64 | #define RTF_LINKRT 0x00100000
65 | #define RTF_NONEXTHOP 0x00200000
66 |
67 | #define RTF_CACHE 0x01000000
68 | #define RTF_FLOW 0x02000000
69 | #define RTF_POLICY 0x04000000
70 |
71 | #define RTCF_VALVE 0x00200000
72 | #define RTCF_MASQ 0x00400000
73 | #define RTCF_NAT 0x00800000
74 | #define RTCF_DOREDIRECT 0x01000000
75 | #define RTCF_LOG 0x02000000
76 | #define RTCF_DIRECTSRC 0x04000000
77 |
78 | #define RTF_LOCAL 0x80000000
79 | #define RTF_INTERFACE 0x40000000
80 | #define RTF_MULTICAST 0x20000000
81 | #define RTF_BROADCAST 0x10000000
82 | #define RTF_NAT 0x08000000
83 |
84 | #define RTF_ADDRCLASSMASK 0xF8000000
85 | #define RT_ADDRCLASS(flags) ((uint32_t) flags >> 23)
86 |
87 | #define RT_TOS(tos) ((tos) & IPTOS_TOS_MASK)
88 |
89 | #define RT_LOCALADDR(flags) ((flags & RTF_ADDRCLASSMASK) \
90 | == (RTF_LOCAL|RTF_INTERFACE))
91 |
92 | #define RT_CLASS_UNSPEC 0
93 | #define RT_CLASS_DEFAULT 253
94 |
95 | #define RT_CLASS_MAIN 254
96 | #define RT_CLASS_LOCAL 255
97 | #define RT_CLASS_MAX 255
98 |
99 |
100 | #define RTMSG_ACK NLMSG_ACK
101 | #define RTMSG_OVERRUN NLMSG_OVERRUN
102 |
103 | #define RTMSG_NEWDEVICE 0x11
104 | #define RTMSG_DELDEVICE 0x12
105 | #define RTMSG_NEWROUTE 0x21
106 | #define RTMSG_DELROUTE 0x22
107 | #define RTMSG_NEWRULE 0x31
108 | #define RTMSG_DELRULE 0x32
109 | #define RTMSG_CONTROL 0x40
110 |
111 | #define RTMSG_AR_FAILED 0x51
112 | #endif
113 |
--------------------------------------------------------------------------------
/kernel/nrf51/Kconfig:
--------------------------------------------------------------------------------
1 | if ARCH_NRF51
2 |
3 | choice
4 | prompt "MCU"
5 | default ARCH_NRF51822_QFAC
6 |
7 | config ARCH_NRF51822_QFAA
8 | bool "NRF51822_QFAA 256KB/16KB"
9 | select FLASH_SIZE_256KB
10 | select RAM_SIZE_16KB
11 | select ARCH_NRF51822
12 | config ARCH_NRF51822_QFAB
13 | bool "NRF51822_QFAB 128KB/16KB"
14 | select FLASH_SIZE_128KB
15 | select RAM_SIZE_16KB
16 | select ARCH_NRF51822
17 | config ARCH_NRF51822_CEAA
18 | bool "NRF51822_CEAA 256KB/16KB"
19 | select FLASH_SIZE_256KB
20 | select RAM_SIZE_16KB
21 | select ARCH_NRF51822
22 | config ARCH_NRF51822_QFAC
23 | bool "NRF51822_QFAC 256KB/32KB"
24 | select FLASH_SIZE_256KB
25 | select RAM_SIZE_32KB
26 | select ARCH_NRF51822
27 | config ARCH_NRF51822_CDAB
28 | bool "NRF51822_CDAB 128KB/16KB"
29 | select FLASH_SIZE_128KB
30 | select RAM_SIZE_16KB
31 | select ARCH_NRF51822
32 | config ARCH_NRF51822_CEAA
33 | bool "NRF51822_CEAA 256KB/16KB"
34 | select FLASH_SIZE_256KB
35 | select RAM_SIZE_16KB
36 | select ARCH_NRF51822
37 | config ARCH_NRF51822_CFAC
38 | bool "NRF51822_CFAC 256KB/32KB"
39 | select FLASH_SIZE_256KB
40 | select RAM_SIZE_32KB
41 | select ARCH_NRF51822
42 | config ARCH_NRF51822_CTAC
43 | bool "NRF51822_CTAC 256KB/32KB"
44 | select FLASH_SIZE_256KB
45 | select RAM_SIZE_32KB
46 | select ARCH_NRF51822
47 | config ARCH_NRF51822_CTAA
48 | bool "NRF51822_CTAA 256KB/16KB"
49 | select FLASH_SIZE_256KB
50 | select RAM_SIZE_16KB
51 | select ARCH_NRF51822
52 | config ARCH_NRF51822_WFAC
53 | bool "NRF51822_WFAC 256KB/32KB"
54 | select FLASH_SIZE_256KB
55 | select RAM_SIZE_32KB
56 | select ARCH_NRF51822
57 | endchoice
58 |
59 | endif
60 |
--------------------------------------------------------------------------------
/kernel/nrf51/blenanov1_5.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Roel Postelmans
18 | *
19 | */
20 | #include "frosted.h"
21 | #include "unicore-mx/nrf/51/uart.h"
22 | #include
23 | #include "gpio.h"
24 | #include "uart.h"
25 |
26 |
27 | static const struct gpio_config Led0 = {
28 | .base=GPIO,
29 | .pin=GPIO19,
30 | .mode=GPIO_DIR_OUTPUT,
31 | .name="led0"
32 | };
33 |
34 | static const struct uart_config uart_configs[] = {
35 | #ifdef CONFIG_DEVUART
36 | #ifdef CONFIG_UART_0
37 | {
38 | .devidx = 0,
39 | .base = UART0,
40 | .irq = NVIC_UART0_IRQ,
41 | .baudrate = UART_BAUD_115200,
42 | .stop_bits = 1,
43 | .data_bits = 8,
44 | .parity = 0,
45 | .flow = 0,
46 | .pio_tx = {
47 | .base=GPIO,
48 | .pin=GPIO9,
49 | .mode=GPIO_MODE_INPUT,
50 | },
51 | .pio_rx = {
52 | .base=GPIO,
53 | .pin=GPIO11,
54 | .mode=GPIO_MODE_OUTPUT,
55 | .pullupdown=GPIO_PUPD_NONE,
56 | },
57 | },
58 | #endif
59 | #endif
60 | };
61 |
62 | int machine_init(void)
63 | {
64 | gpio_create(NULL, &Led0);
65 | uart_create(&uart_configs[0]);
66 |
67 | return 0;
68 | }
69 |
--------------------------------------------------------------------------------
/kernel/nrf51/nrf51.ld.in:
--------------------------------------------------------------------------------
1 | MEMORY
2 | {
3 | FLASH (rx) : ORIGIN = __FLASH_ORIGIN, LENGTH = __KFLASHMEM_SIZE
4 | SRAM (rwx) : ORIGIN = __RAM1_BASE, LENGTH = __KRAMMEM_SIZE
5 | SRAM_USER (rwx) : ORIGIN = (__RAM1_BASE + __KRAMMEM_SIZE), LENGTH = (__RAM1_SIZE - __KRAMMEM_SIZE)
6 | }
7 |
8 | /* Enforce emmition of the vector table. */
9 | EXTERN (vector_table)
10 |
11 | /* Define the entry point of the output file. */
12 | ENTRY(reset_handler)
13 |
14 | SECTIONS
15 | {
16 | .text :
17 | {
18 | KEEP(*(.vectors))
19 | *(.text*)
20 | *(.rodata*)
21 | } > FLASH
22 | /* C++ Static constructors/destructors, also used for __attribute__
23 | * ((constructor)) and the likes */
24 | .preinit_array : {
25 | . = ALIGN(4);
26 | __preinit_array_start = .;
27 | KEEP (*(.preinit_array))
28 | __preinit_array_end = .;
29 | } > FLASH
30 | .init_array : {
31 | . = ALIGN(4);
32 | __init_array_start = .;
33 | KEEP (*(SORT(.init_array.*)))
34 | KEEP (*(.init_array))
35 | __init_array_end = .;
36 | } > FLASH
37 | .fini_array : {
38 | . = ALIGN(4);
39 | __fini_array_start = .;
40 | KEEP (*(.fini_array))
41 | KEEP (*(SORT(.fini_array.*)))
42 | __fini_array_end = .;
43 | } > FLASH
44 |
45 | .data :
46 | {
47 | _etext = LOADADDR(.data);
48 | _data = .;
49 | *(vtable)
50 | *(.data*)
51 | _edata = .;
52 | } > SRAM AT > FLASH
53 | _data_loadaddr = LOADADDR(.data);
54 |
55 | .bss :
56 | {
57 | _bss = .;
58 | *(.bss*)
59 | *(COMMON)
60 | . = ALIGN(32 / 8);
61 | _ebss = .;
62 | PROVIDE (end = .);
63 | } > SRAM
64 |
65 | .heap :
66 | {
67 | /* heap starts after BSS */
68 | PROVIDE(_heap_start = _ebss );
69 | } > SRAM
70 | }
71 |
72 | PROVIDE(_stack = ORIGIN(SRAM) + LENGTH(SRAM));
73 | PROVIDE(_user_heap_start = ORIGIN(SRAM_USER));
74 | PROVIDE(_user_heap_end = ORIGIN(SRAM_USER) + LENGTH(SRAM_USER));
75 |
--------------------------------------------------------------------------------
/kernel/nrf52/Kconfig:
--------------------------------------------------------------------------------
1 | if ARCH_NRF52
2 |
3 | choice
4 | prompt "MCU"
5 | default ARCH_NRF52832
6 |
7 | config ARCH_NRF52840
8 | bool "NRF52840 1MB/512KB"
9 | select FLASH_SIZE_1MB
10 | select RAM_SIZE_512KB
11 | config ARCH_NRF52832
12 | bool "NRF52832 512KB/64KB"
13 | select FLASH_SIZE_512KB
14 | select RAM_SIZE_64KB
15 | config ARCH_NRF52810
16 | bool "NRF52810 192KB/24KB"
17 | select FLASH_SIZE_192KB
18 | select RAM_SIZE_24KB
19 | endchoice
20 |
21 | endif
22 |
--------------------------------------------------------------------------------
/kernel/nrf52/blenanov2_0.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Roel Postelmans
18 | *
19 | */
20 | #include "frosted.h"
21 | #include "unicore-mx/nrf/52/uart.h"
22 | #include
23 | #include "gpio.h"
24 | #include "uart.h"
25 |
26 |
27 | static const struct gpio_config Led0 = {
28 | .base=GPIO,
29 | .pin=GPIO11,
30 | .mode=GPIO_DIR_OUTPUT,
31 | .name="led0"
32 | };
33 |
34 | static const struct uart_config uart_configs[] = {
35 | #ifdef CONFIG_DEVUART
36 | #ifdef CONFIG_UART_0
37 | {
38 | .devidx = 0,
39 | .base = UART0,
40 | .irq = NVIC_UART0_IRQ,
41 | .baudrate = UART_BAUD_115200,
42 | .stop_bits = 1,
43 | .data_bits = 8,
44 | .parity = 0,
45 | .flow = 0,
46 | .pio_tx = {
47 | .base=GPIO,
48 | .pin=GPIO29,
49 | .mode=GPIO_MODE_OUTPUT,
50 | },
51 | .pio_rx = {
52 | .base=GPIO,
53 | .pin=GPIO30,
54 | .mode=GPIO_MODE_INPUT,
55 | .pullupdown=GPIO_PUPD_NONE,
56 | },
57 | },
58 | #endif
59 | #endif
60 | };
61 |
62 | int machine_init(void)
63 | {
64 | gpio_create(NULL, &Led0);
65 | uart_create(&uart_configs[0]);
66 |
67 |
68 | return 0;
69 | }
70 |
--------------------------------------------------------------------------------
/kernel/nrf52/nrf52.ld.in:
--------------------------------------------------------------------------------
1 | MEMORY
2 | {
3 | FLASH (rx) : ORIGIN = __FLASH_ORIGIN, LENGTH = __KFLASHMEM_SIZE
4 | SRAM (rwx) : ORIGIN = __RAM1_BASE, LENGTH = __KRAMMEM_SIZE
5 | SRAM_USER (rwx) : ORIGIN = (__RAM1_BASE + __KRAMMEM_SIZE), LENGTH = (__RAM1_SIZE - __KRAMMEM_SIZE)
6 | }
7 |
8 | /* Enforce emmition of the vector table. */
9 | EXTERN (vector_table)
10 |
11 | /* Define the entry point of the output file. */
12 | ENTRY(reset_handler)
13 |
14 | SECTIONS
15 | {
16 | .text :
17 | {
18 | KEEP(*(.vectors))
19 | *(.text*)
20 | *(.rodata*)
21 | } > FLASH
22 | /* C++ Static constructors/destructors, also used for __attribute__
23 | * ((constructor)) and the likes */
24 | .preinit_array : {
25 | . = ALIGN(4);
26 | __preinit_array_start = .;
27 | KEEP (*(.preinit_array))
28 | __preinit_array_end = .;
29 | } > FLASH
30 | .init_array : {
31 | . = ALIGN(4);
32 | __init_array_start = .;
33 | KEEP (*(SORT(.init_array.*)))
34 | KEEP (*(.init_array))
35 | __init_array_end = .;
36 | } > FLASH
37 | .fini_array : {
38 | . = ALIGN(4);
39 | __fini_array_start = .;
40 | KEEP (*(.fini_array))
41 | KEEP (*(SORT(.fini_array.*)))
42 | __fini_array_end = .;
43 | } > FLASH
44 |
45 | .data :
46 | {
47 | _etext = LOADADDR(.data);
48 | _data = .;
49 | *(vtable)
50 | *(.data*)
51 | _edata = .;
52 | } > SRAM AT > FLASH
53 | _data_loadaddr = LOADADDR(.data);
54 |
55 | .bss :
56 | {
57 | _bss = .;
58 | *(.bss*)
59 | *(COMMON)
60 | . = ALIGN(32 / 8);
61 | _ebss = .;
62 | PROVIDE (end = .);
63 | } > SRAM
64 |
65 | .heap :
66 | {
67 | /* heap starts after BSS */
68 | PROVIDE(_heap_start = _ebss );
69 | } > SRAM
70 | }
71 |
72 | PROVIDE(_stack = ORIGIN(SRAM) + LENGTH(SRAM));
73 | PROVIDE(_user_heap_start = ORIGIN(SRAM_USER));
74 | PROVIDE(_user_heap_end = ORIGIN(SRAM_USER) + LENGTH(SRAM_USER));
75 |
--------------------------------------------------------------------------------
/kernel/null.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_NULL
2 | #define INC_NULL
3 |
4 | void devnull_init(struct fnode *dev);
5 |
6 | #endif
7 |
8 |
--------------------------------------------------------------------------------
/kernel/pico_port.h:
--------------------------------------------------------------------------------
1 | #ifndef PICO_PORT_FROSTED_INCLUDED
2 | #define PICO_PORT_FROSTED_INCLUDED
3 | #define PICO_SUPPORT_MUTEX
4 |
5 | #ifdef FROSTED
6 | #include "frosted.h"
7 | #include "string.h"
8 | #include "malloc.h"
9 | #include "locks.h"
10 | #include "kprintf.h"
11 |
12 |
13 |
14 | #define pico_free(x) f_free(x)
15 | #define pico_zalloc(x) f_calloc(MEM_TCPIP, x, 1)
16 |
17 | static void *pico_mutex_init(void) {
18 | return mutex_init();
19 | }
20 |
21 | static void pico_mutex_lock(void *m) {
22 | mutex_lock((mutex_t *)m);
23 | }
24 |
25 | static void pico_mutex_unlock(void *m) {
26 | mutex_unlock((mutex_t *)m);
27 | }
28 |
29 | static void pico_mutex_deinit(void *m) {
30 | mutex_destroy((mutex_t *)m);
31 | }
32 |
33 | #define dbg kprintf
34 |
35 | static inline pico_time PICO_TIME_MS()
36 | {
37 | return jiffies;
38 | }
39 |
40 | static inline pico_time PICO_TIME()
41 | {
42 | return jiffies / 1000;
43 | }
44 |
45 | static inline void PICO_IDLE(void)
46 | {
47 | }
48 |
49 | #else
50 |
51 | #error "file pico_port.h included, but no FROSTED define."
52 |
53 | #endif
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/kernel/scheduler.h:
--------------------------------------------------------------------------------
1 | #ifndef INCLUDED_SCHEDULER_H
2 | #define INCLUDED_SCHEDULER_H
3 | #include "vfs.h"
4 |
5 | #endif
6 |
--------------------------------------------------------------------------------
/kernel/semaphore.S:
--------------------------------------------------------------------------------
1 |
2 | .syntax unified
3 |
4 | /* Try to decrease the semaphore.
5 | * On success, return 0.
6 | * On failure, return -1 (sem == 0, try again later).
7 | */
8 |
9 | .global _sem_wait
10 | _sem_wait:
11 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
12 | LDREX r1, [r0]
13 | #elif defined(__ARM_ARCH_6M__)
14 | CPSID i
15 | LDR r1, [r0]
16 | #endif
17 | CMP r1, #0 // Test if semaphore holds the value 0
18 | BEQ _sem_wait_fail // If it does, return 0
19 | SUBS r1, #1 // If not, decrement temporary copy
20 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
21 | STREX r2, r1, [r0] // Attempt Store-Exclusive
22 | CMP r2, #0 // Check if Store-Exclusive succeeded
23 | BNE _sem_wait // If Store-Exclusive failed, retry from start
24 | DMB // Required before accessing protected resource
25 | #elif defined(__ARM_ARCH_6M__)
26 | STR r1, [r0]
27 | CPSIE i
28 | #endif
29 | MOVS r0, #0 // Successfully acquired.
30 | BX lr
31 | _sem_wait_fail:
32 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
33 | DMB
34 | MOV r0, #-1 // Already locked!
35 | #elif defined(__ARM_ARCH_6M__)
36 | CPSIE i
37 | MOVS r2, #0 // Already locked!
38 | MVNS r0, r2
39 | #endif
40 | BX lr
41 |
42 | /* Increase the semaphore value.
43 | * If the value was 0, return 1 (send a signal to the listeners)
44 | * If a non-zero semaphore is incremented, return 0. (do not signal).
45 | */
46 |
47 | .global _sem_post
48 | _sem_post:
49 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
50 | LDREX r1, [r0]
51 | #elif defined(__ARM_ARCH_6M__)
52 | CPSID i
53 | LDR r1, [r0]
54 | #endif
55 | ADDS r1, #1 // Increment temporary copy
56 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__)
57 | STREX r2, r1, [r0] // Attempt Store-Exclusive
58 | CMP r2, #0 // Check if Store-Exclusive succeeded
59 | BNE _sem_post // Store failed - retry immediately
60 | #elif defined(__ARM_ARCH_6M__)
61 | STR r1, [r0]
62 | CPSIE i
63 | #endif
64 | CMP r0, #1 // Store successful - test if incremented from zero
65 | DMB // Required before releasing protected resource
66 | BGE _sem_signal_up // If initial value was 0, signal update
67 | MOVS r0, #0
68 | BX lr
69 | _sem_signal_up:
70 | MOVS r0, #1 // Semaphore was 0, send a signal to listeners.
71 | BX lr
72 |
73 |
--------------------------------------------------------------------------------
/kernel/stm32f4/Kconfig:
--------------------------------------------------------------------------------
1 | if ARCH_STM32F4
2 |
3 | choice
4 | prompt "MCU"
5 | default ARCH_STM32F407_XG
6 |
7 | config ARCH_STM32F401_XB
8 | bool "STM32F401xB 128KB"
9 | select FLASH_SIZE_128KB
10 | select RAM_SIZE_64KB
11 | select ARCH_STM32F401
12 | config ARCH_STM32F401_XC
13 | bool "STM32F401xC 256KB"
14 | select FLASH_SIZE_256KB
15 | select RAM_SIZE_64KB
16 | select ARCH_STM32F401
17 | config ARCH_STM32F401_XD
18 | bool "STM32F401xD 384KB"
19 | select FLASH_SIZE_384KB
20 | select RAM_SIZE_96KB
21 | select ARCH_STM32F401
22 | config ARCH_STM32F401_XE
23 | bool "STM32F401xE 512KB"
24 | select FLASH_SIZE_512KB
25 | select RAM_SIZE_96KB
26 | select ARCH_STM32F401
27 |
28 | config ARCH_STM32F405_XG
29 | bool "STM32F405xG 1MB"
30 | select FLASH_SIZE_1MB
31 | select RAM_SIZE_192KB
32 | select ARCH_STM32F405
33 | config ARCH_STM32F405_XE
34 | bool "STM32F407xE 512KB"
35 | select FLASH_SIZE_512KB
36 | select RAM_SIZE_192KB
37 | select ARCH_STM32F405
38 |
39 | config ARCH_STM32F407_XG
40 | bool "STM32F407xG 1MB"
41 | select FLASH_SIZE_1MB
42 | select RAM_SIZE_192KB
43 | select ARCH_STM32F407
44 | config ARCH_STM32F407_XE
45 | bool "STM32F407xE 512KB"
46 | select FLASH_SIZE_512KB
47 | select RAM_SIZE_192KB
48 | select ARCH_STM32F407
49 |
50 | config ARCH_STM32F411_XE
51 | bool "STM32F411xE 512KB"
52 | select FLASH_SIZE_512KB
53 | select RAM_SIZE_128KB
54 | select ARCH_STM32F411
55 | config ARCH_STM32F411_XC
56 | bool "STM32F411xC 256KB"
57 | select FLASH_SIZE_256KB
58 | select RAM_SIZE_128KB
59 | select ARCH_STM32F411
60 |
61 | config ARCH_STM32F429_XE
62 | bool "STM32F429xE 512KB"
63 | select FLASH_SIZE_512KB
64 | select RAM_SIZE_256KB
65 | select ARCH_STM32F429
66 | config ARCH_STM32F429_XG
67 | bool "STM32F429xG 1MB"
68 | select FLASH_SIZE_1MB
69 | select RAM_SIZE_256KB
70 | select ARCH_STM32F429
71 | config ARCH_STM32F429_XI
72 | bool "STM32F429xI 2MB"
73 | select FLASH_SIZE_2MB
74 | select RAM_SIZE_256KB
75 | select ARCH_STM32F429
76 | config ARCH_STM32F446_ZE
77 | bool "STM32F446ZE 512KB"
78 | select FLASH_SIZE_512KB
79 | select RAM_SIZE_128KB
80 | select ARCH_STM32F446
81 | endchoice
82 |
83 | endif
84 |
--------------------------------------------------------------------------------
/kernel/stm32f4/stm32f4.ld.in:
--------------------------------------------------------------------------------
1 | MEMORY
2 | {
3 | FLASH (rx) : ORIGIN = __FLASH_ORIGIN, LENGTH = __KFLASHMEM_SIZE
4 | SRAM (rwx) : ORIGIN = __RAM1_BASE, LENGTH = __KRAMMEM_SIZE
5 | SRAM_USER (rwx) : ORIGIN = (__RAM1_BASE + __KRAMMEM_SIZE), LENGTH = (__RAM1_SIZE - __KRAMMEM_SIZE)
6 | SRAM_EXTRA (rwx) : ORIGIN = __RAM2_BASE, LENGTH = __RAM2_SIZE
7 | SDRAM_USER(rwx) : ORIGIN = __SDRAM_BASE, LENGTH = __SDRAM_SIZE
8 | }
9 |
10 | /* Enforce emmition of the vector table. */
11 | EXTERN (vector_table)
12 |
13 | /* Define the entry point of the output file. */
14 | ENTRY(reset_handler)
15 |
16 | SECTIONS
17 | {
18 | .text :
19 | {
20 | KEEP(*(.vectors))
21 | *(.text*)
22 | *(.rodata*)
23 | } > FLASH
24 | /* C++ Static constructors/destructors, also used for __attribute__
25 | * ((constructor)) and the likes */
26 | .preinit_array : {
27 | . = ALIGN(4);
28 | __preinit_array_start = .;
29 | KEEP (*(.preinit_array))
30 | __preinit_array_end = .;
31 | } > FLASH
32 | .init_array : {
33 | . = ALIGN(4);
34 | __init_array_start = .;
35 | KEEP (*(SORT(.init_array.*)))
36 | KEEP (*(.init_array))
37 | __init_array_end = .;
38 | } > FLASH
39 | .fini_array : {
40 | . = ALIGN(4);
41 | __fini_array_start = .;
42 | KEEP (*(.fini_array))
43 | KEEP (*(SORT(.fini_array.*)))
44 | __fini_array_end = .;
45 | } > FLASH
46 |
47 | .data :
48 | {
49 | _etext = LOADADDR(.data);
50 | _data = .;
51 | *(vtable)
52 | *(.data*)
53 | _edata = .;
54 | } > SRAM AT > FLASH
55 | _data_loadaddr = LOADADDR(.data);
56 |
57 | .bss :
58 | {
59 | _bss = .;
60 | *(.bss*)
61 | *(COMMON)
62 | . = ALIGN(32 / 8);
63 | _ebss = .;
64 | PROVIDE (end = .);
65 | } > SRAM
66 |
67 | .heap :
68 | {
69 | /* heap starts after BSS */
70 | PROVIDE(_heap_start = _ebss );
71 | } > SRAM
72 | }
73 |
74 | PROVIDE(_stack = ORIGIN(SRAM) + LENGTH(SRAM));
75 | PROVIDE(_user_heap_start = ORIGIN(SRAM_USER));
76 | PROVIDE(_user_heap_end = ORIGIN(SRAM_USER) + LENGTH(SRAM_USER));
77 | PROVIDE(_extra_heap_start = ORIGIN(SRAM_EXTRA));
78 | PROVIDE(_extra_heap_end = ORIGIN(SRAM_EXTRA) + LENGTH(SRAM_EXTRA));
79 | PROVIDE(_external_heap_start = ORIGIN(SDRAM_USER));
80 | PROVIDE(_external_heap_end = ORIGIN(SDRAM_USER) + LENGTH(SDRAM_USER));
81 |
82 |
--------------------------------------------------------------------------------
/kernel/stm32f7/Kconfig:
--------------------------------------------------------------------------------
1 | if ARCH_STM32F7
2 |
3 | choice
4 | prompt "MCU"
5 | default ARCH_STM32F746_NG
6 |
7 | config ARCH_STM32F746_NG
8 | bool "STM32F746NG 1MB"
9 | select FLASH_SIZE_1MB
10 | select RAM_SIZE_320KB
11 | select ARCH_STM32F746
12 |
13 | config ARCH_STM32F769_NI
14 | bool "STM32F769NI 2MB"
15 | select FLASH_SIZE_2MB
16 | select RAM_SIZE_368KB
17 | select ARCH_STM32F769
18 |
19 | endchoice
20 |
21 | endif
22 |
--------------------------------------------------------------------------------
/kernel/stm32f7/stm32f7.ld.in:
--------------------------------------------------------------------------------
1 | MEMORY
2 | {
3 | FLASH (rx) : ORIGIN = __FLASH_ORIGIN, LENGTH = __KFLASHMEM_SIZE
4 | SRAM (rwx) : ORIGIN = __RAM1_BASE, LENGTH = __KRAMMEM_SIZE
5 | SRAM_USER (rwx) : ORIGIN = (__RAM1_BASE + __KRAMMEM_SIZE), LENGTH = (__RAM1_SIZE - __KRAMMEM_SIZE)
6 | SDRAM_USER(rwx) : ORIGIN = __SDRAM_BASE, LENGTH = __SDRAM_SIZE
7 | }
8 |
9 | /* Enforce emmition of the vector table. */
10 | EXTERN (vector_table)
11 |
12 | /* Define the entry point of the output file. */
13 | ENTRY(reset_handler)
14 |
15 | SECTIONS
16 | {
17 | .text :
18 | {
19 | KEEP(*(.vectors))
20 | *(.text*)
21 | *(.rodata*)
22 | } > FLASH
23 | /* C++ Static constructors/destructors, also used for __attribute__
24 | * ((constructor)) and the likes */
25 | .preinit_array : {
26 | . = ALIGN(4);
27 | __preinit_array_start = .;
28 | KEEP (*(.preinit_array))
29 | __preinit_array_end = .;
30 | } > FLASH
31 | .init_array : {
32 | . = ALIGN(4);
33 | __init_array_start = .;
34 | KEEP (*(SORT(.init_array.*)))
35 | KEEP (*(.init_array))
36 | __init_array_end = .;
37 | } > FLASH
38 | .fini_array : {
39 | . = ALIGN(4);
40 | __fini_array_start = .;
41 | KEEP (*(.fini_array))
42 | KEEP (*(SORT(.fini_array.*)))
43 | __fini_array_end = .;
44 | } > FLASH
45 |
46 | .data :
47 | {
48 | _etext = LOADADDR(.data);
49 | _data = .;
50 | *(vtable)
51 | *(.data*)
52 | _edata = .;
53 | } > SRAM AT > FLASH
54 | _data_loadaddr = LOADADDR(.data);
55 |
56 | .bss :
57 | {
58 | _bss = .;
59 | *(.bss*)
60 | *(COMMON)
61 | . = ALIGN(32 / 8);
62 | _ebss = .;
63 | PROVIDE (end = .);
64 | } > SRAM
65 |
66 | .heap :
67 | {
68 | /* heap starts after BSS */
69 | PROVIDE(_heap_start = _ebss );
70 | } > SRAM
71 | }
72 |
73 | PROVIDE(_stack = ORIGIN(SRAM) + LENGTH(SRAM));
74 | PROVIDE(_user_heap_start = ORIGIN(SRAM_USER));
75 | PROVIDE(_user_heap_end = ORIGIN(SRAM_USER) + LENGTH(SRAM_USER));
76 | PROVIDE(_external_heap_start = ORIGIN(SDRAM_USER));
77 | PROVIDE(_external_heap_end = ORIGIN(SDRAM_USER) + LENGTH(SDRAM_USER));
78 | PROVIDE(_extra_heap_start = ORIGIN(SDRAM_USER));
79 | PROVIDE(_extra_heap_end = ORIGIN(SDRAM_USER) + LENGTH(SDRAM_USER));
80 |
81 |
--------------------------------------------------------------------------------
/kernel/string.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera, Maxime Vincent, brabo
18 | *
19 | */
20 |
21 | #include
22 | #include
23 |
24 | void *memset(void *s, int c, size_t n)
25 | {
26 | unsigned char *d = (unsigned char *)s;
27 |
28 | while (n--) {
29 | *d++ = (unsigned char)c;
30 | }
31 |
32 | return s;
33 | }
34 |
35 | char *strcat(char *dest, const char *src)
36 | {
37 | int i = 0;
38 | int j = strlen(dest);
39 |
40 | for (i = 0; i < strlen(src); i++) {
41 | dest[j++] = src[i];
42 | }
43 | dest[j] = '\0';
44 |
45 | return dest;
46 | }
47 |
48 | int strcmp(const char *s1, const char *s2)
49 | {
50 | int diff = 0;
51 |
52 | while (!diff && *s1) {
53 | diff = (int)*s1 - (int)*s2;
54 | s1++;
55 | s2++;
56 | }
57 |
58 | return diff;
59 | }
60 |
61 | int strcasecmp(const char *s1, const char *s2)
62 | {
63 | int diff = 0;
64 |
65 | while (!diff && *s1) {
66 | diff = (int)*s1 - (int)*s2;
67 |
68 | if ((diff == 'A' - 'a') || (diff == 'a' - 'A'))
69 | diff = 0;
70 |
71 | s1++;
72 | s2++;
73 | }
74 |
75 | return diff;
76 | }
77 |
78 | size_t strlen(const char *s)
79 | {
80 | int i = 0;
81 |
82 | while (s[i] != 0)
83 | i++;
84 |
85 | return i;
86 | }
87 |
88 | char *strncat(char *dest, const char *src, size_t n)
89 | {
90 | int i = 0;
91 | int j = strlen(dest);
92 |
93 | for (i = 0; i < strlen(src); i++) {
94 | if (j >= (n - 1)) {
95 | break;
96 | }
97 | dest[j++] = src[i];
98 | }
99 | dest[j] = '\0';
100 |
101 | return dest;
102 | }
103 |
104 | int strncmp(const char *s1, const char *s2, size_t n)
105 | {
106 | int diff = 0;
107 |
108 | while (n > 0) {
109 | diff = (unsigned char)*s1 - (unsigned char)*s2;
110 | if (diff || !*s1)
111 | break;
112 | s1++;
113 | s2++;
114 | n--;
115 | }
116 |
117 | return diff;
118 | }
119 |
120 | void *memcpy(void *dst, const void *src, size_t n)
121 | {
122 | int i;
123 | const char *s = (const char *)src;
124 | char *d = (char *)dst;
125 |
126 | for (i = 0; i < n; i++) {
127 | d[i] = s[i];
128 | }
129 |
130 | return dst;
131 | }
132 |
133 | char *strncpy(char *dst, const char *src, size_t n)
134 | {
135 | int i;
136 |
137 | for (i = 0; i < n; i++) {
138 | dst[i] = src[i];
139 | if (src[i] == '\0')
140 | break;
141 | }
142 |
143 | return dst;
144 | }
145 |
146 | char *strcpy(char *dst, const char *src)
147 | {
148 | int i = 0;
149 |
150 | while(1 < 2) {
151 | dst[i] = src[i];
152 | if (src[i] == '\0')
153 | break;
154 | i++;
155 | }
156 |
157 | return dst;
158 | }
159 |
160 | int memcmp(const void *_s1, const void *_s2, size_t n)
161 | {
162 | int diff = 0;
163 | const unsigned char *s1 = (const unsigned char *)_s1;
164 | const unsigned char *s2 = (const unsigned char *)_s2;
165 |
166 | while (!diff && n) {
167 | diff = (int)*s1 - (int)*s2;
168 | s1++;
169 | s2++;
170 | n--;
171 | }
172 |
173 | return diff;
174 | }
175 |
--------------------------------------------------------------------------------
/kernel/string.h:
--------------------------------------------------------------------------------
1 | #ifndef FLIBC_STRING_H
2 | #define FLIBC_STRING_H
3 |
4 | #include
5 |
6 | extern void * memset(void *s, int c, size_t n);
7 | extern void *memcpy(void *dst, const void *src, size_t n);
8 | extern int memcmp(const void *s1, const void *s2, size_t n);
9 | extern int strcmp(const char *s1, const char *s2);
10 | extern int strncmp(const char *s1, const char *s2, size_t n);
11 | extern char *strcat(char *dest, const char *src);
12 | extern char *strncat(char *dest, const char *src, size_t n);
13 | extern size_t strlen(const char *s);
14 | extern char *strcpy(char *dst, const char *src);
15 | char *strncpy(char *dst, const char *src, size_t n);
16 |
17 |
18 | #endif /* FLIBC_STRING_H */
19 |
--------------------------------------------------------------------------------
/kernel/systick.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera, Maxime Vincent
18 | *
19 | */
20 | #include "frosted.h"
21 | #include "heap.h"
22 | #include "lowpower.h"
23 | #include "unicore-mx/cm3/nvic.h"
24 | #include "unicore-mx/cm3/systick.h"
25 | #include "unicore-mx/cm3/scb.h"
26 | #define SEV() asm volatile ("sev")
27 |
28 | #ifdef NRF51
29 | #include "unicore-mx/nrf/51/ostick.h"
30 | #endif
31 |
32 | volatile unsigned int jiffies = 0u;
33 | volatile unsigned int _n_int = 0u;
34 | volatile int ktimer_check_pending = 0;
35 | volatile int sleep_mode = 0;
36 | static int _sched_active = 0;
37 |
38 | void frosted_scheduler_on(void)
39 | {
40 | nvic_set_priority(NVIC_PENDSV_IRQ, 2);
41 | nvic_set_priority(NVIC_SV_CALL_IRQ, 1);
42 | #ifdef CUSTOM_SYSTICK
43 | ostick_init(1, &sys_tick_handler);
44 | ostick_start();
45 | #else
46 | nvic_set_priority(NVIC_SYSTICK_IRQ, 0);
47 | nvic_enable_irq(NVIC_SYSTICK_IRQ);
48 | systick_counter_enable();
49 | systick_interrupt_enable();
50 | #endif
51 | _sched_active = 1;
52 | }
53 |
54 | void frosted_scheduler_off(void)
55 | {
56 | _sched_active = 0;
57 | }
58 |
59 | void __attribute__((weak)) SysTick_Hook(void)
60 | {
61 | }
62 |
63 | typedef struct ktimer {
64 | uint32_t expire_time;
65 | void *arg;
66 | void (*handler)(uint32_t time, void *arg);
67 | } ktimer;
68 |
69 | DECLARE_HEAP(ktimer, expire_time);
70 | static struct heap_ktimer *ktimer_list = NULL;
71 |
72 | /* Init function */
73 | void ktimer_init(void)
74 | {
75 | ktimer_list = heap_init();
76 | }
77 |
78 | /* Add kernel timer */
79 | int ktimer_add(uint32_t count, void (*handler)(uint32_t, void *), void *arg)
80 | {
81 | struct ktimer t;
82 | int ret;
83 | memset(&t, 0, sizeof(t));
84 | t.expire_time = jiffies + count;
85 | t.handler = handler;
86 | t.arg = arg;
87 | if (!task_in_syscall())
88 | irq_off();
89 | ret = heap_insert(ktimer_list, &t);
90 | if (!task_in_syscall())
91 | irq_on();
92 | return ret;
93 | }
94 |
95 | /* Delete kernel timer */
96 | int ktimer_del(int tid)
97 | {
98 | int ret;
99 | if (tid < 0)
100 | return -1;
101 | if (!task_in_syscall())
102 | irq_off();
103 | ret = heap_delete(ktimer_list, tid);
104 | if (!task_in_syscall())
105 | irq_on();
106 | return ret;
107 | }
108 |
109 | static inline int ktimer_expired(void)
110 | {
111 | struct ktimer *t;
112 | return ((ktimer_list) && (ktimer_list->n > 0) &&
113 | (t = heap_first(ktimer_list)) && (t->expire_time < jiffies));
114 | }
115 |
116 |
117 | /* Tasklet that checks expired timers */
118 | static void ktimers_check_tasklet(void *arg)
119 | {
120 | struct ktimer *t;
121 | struct ktimer t_previous;
122 | int next_t;
123 | uint32_t this_timeslice;
124 |
125 | next_t = -1;
126 |
127 | if ((ktimer_list) && (ktimer_list->n > 0)) {
128 | irq_off();
129 | t = heap_first(ktimer_list);
130 | irq_on();
131 |
132 | while ((t) && (t->expire_time < jiffies)) {
133 | if (t->handler) {
134 | t->handler(jiffies, t->arg);
135 | }
136 | irq_off();
137 | heap_peek(ktimer_list, &t_previous);
138 | t = heap_first(ktimer_list);
139 | irq_on();
140 | }
141 | next_t = (t->expire_time - jiffies);
142 | }
143 |
144 | ktimer_check_pending = 0;
145 | }
146 |
147 | void sys_tick_handler(void)
148 | {
149 | uint32_t next_timer = 0;
150 | volatile uint32_t reload = systick_get_reload();
151 | uint32_t this_timeslice;
152 | SysTick_Hook();
153 | jiffies ++;
154 | _n_int++;
155 |
156 | if (ktimer_expired()) {
157 | task_preempt_all();
158 | goto end;
159 | }
160 |
161 | if (_sched_active && ((task_timeslice() == 0) || (!task_running()))) {
162 | schedule();
163 | (void)next_timer;
164 | }
165 | end:
166 | if (!ktimer_check_pending) {
167 | ktimer_check_pending++;
168 | tasklet_add(ktimers_check_tasklet, NULL);
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/kernel/tasklet.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera, Maxime Vincent
18 | *
19 | */
20 | #include "frosted.h"
21 | #include "unicore-mx/cm3/systick.h"
22 |
23 | #define MAX_TASKLETS 64
24 |
25 | struct tasklet {
26 | void (*exe)(void *);
27 | void *arg;
28 | };
29 |
30 | static struct tasklet tasklet_array[MAX_TASKLETS];
31 | uint32_t n_tasklets = 0;
32 | uint32_t max_tasklets = 0;
33 |
34 |
35 | void tasklet_add(void (*exe)(void*), void *arg)
36 | {
37 | int i;
38 | if (!task_in_syscall())
39 | irq_off();
40 | for (i = 0; i < MAX_TASKLETS; i++) {
41 | if (!tasklet_array[i].exe) {
42 | tasklet_array[i].exe = exe;
43 | tasklet_array[i].arg = arg;
44 | n_tasklets++;
45 | if (n_tasklets > max_tasklets)
46 | max_tasklets = n_tasklets;
47 | if (!task_in_syscall())
48 | irq_on();
49 | return;
50 | }
51 | }
52 | while(1) { /* Too many tasklets. */; }
53 |
54 | }
55 |
56 | void check_tasklets(void)
57 | {
58 | int i;
59 | if (n_tasklets == 0)
60 | return;
61 | irq_off();
62 | for (i = 0; i < MAX_TASKLETS; i++) {
63 | if (tasklet_array[i].exe) {
64 | tasklet_array[i].exe(tasklet_array[i].arg);
65 | tasklet_array[i].exe = NULL;
66 | tasklet_array[i].arg = NULL;
67 | n_tasklets--;
68 | }
69 | }
70 | irq_on();
71 | }
72 |
--------------------------------------------------------------------------------
/kernel/term.c:
--------------------------------------------------------------------------------
1 | /*
2 | * This file is part of frosted.
3 | *
4 | * frosted is free software: you can redistribute it and/or modify
5 | * it under the terms of the GNU General Public License version 2, as
6 | * published by the Free Software Foundation.
7 | *
8 | *
9 | * frosted is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | * GNU General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with frosted. If not, see .
16 | *
17 | * Authors: Daniele Lacamera, Maxime Vincent
18 | *
19 | */
20 | #include "frosted.h"
21 | #include
22 | #include
23 |
24 | static struct module *get_term_mod(int td)
25 | {
26 | struct fnode *f = task_filedesc_get(td);
27 | if (f)
28 | return f->owner;
29 | return NULL;
30 | }
31 |
32 | int sys_tcgetattr_hdlr(int arg1, int arg2)
33 | {
34 | struct termios *t = (struct termios *)arg2;
35 | struct module *m;
36 | if (task_ptr_valid(t))
37 | return -EACCES;
38 | m = get_term_mod(arg1);
39 | if (m && m->ops.tcgetattr)
40 | return m->ops.tcgetattr(arg1, t);
41 | else
42 | return -EOPNOTSUPP;
43 | }
44 |
45 | int sys_tcsetattr_hdlr(int arg1, int arg2, int arg3)
46 | {
47 | const struct termios *t = (const struct termios *)arg3;
48 | struct module *m;
49 | if (task_ptr_valid(t))
50 | return -EACCES;
51 | m = get_term_mod(arg1);
52 | if (m && m->ops.tcsetattr)
53 | return m->ops.tcsetattr(arg1, arg2, t);
54 | else
55 | return -EOPNOTSUPP;
56 | }
57 |
58 |
59 | int sys_tcsendbreak_hdlr(int arg1, int arg2)
60 | {
61 | /* TODO: send SIGINT to self. */
62 | return -EOPNOTSUPP;
63 | }
64 |
--------------------------------------------------------------------------------
/kernel/vfs.h:
--------------------------------------------------------------------------------
1 | #ifndef INC_VFS
2 | #define INC_VFS
3 |
4 |
5 | #define VFS_TYPE_BIN (0) /* flat binary */
6 | #define VFS_TYPE_BFLT (1) /* bFLT binary */
7 |
8 | struct vfs_info {
9 | int type;
10 | int pic;
11 | void (*init)(void *);
12 | void * allocated;
13 | uint32_t text_size;
14 | uint32_t data_size;
15 | };
16 |
17 |
18 | #endif /* INC_VFS */
19 |
--------------------------------------------------------------------------------
/qemu.gdbinit:
--------------------------------------------------------------------------------
1 | tar ext :3333
2 | layout src
3 | file kernel.elf
4 | stepi
5 | focus c
6 |
--------------------------------------------------------------------------------
/rules/arch.mk:
--------------------------------------------------------------------------------
1 |
2 | ###### STACK SIZE #######
3 | ifeq ($(TASK_STACK_SIZE_1K),y)
4 | TASK_STACK_SIZE=1024
5 | endif
6 | ifeq ($(TASK_STACK_SIZE_2K),y)
7 | TASK_STACK_SIZE=2048
8 | endif
9 | ifeq ($(TASK_STACK_SIZE_4K),y)
10 | TASK_STACK_SIZE=4096
11 | endif
12 | ifeq ($(TASK_STACK_SIZE_8K),y)
13 | TASK_STACK_SIZE=8192
14 | endif
15 |
16 | #########################
17 | #Target flags
18 | CROSS_COMPILE?=arm-frosted-eabi-
19 | CC:=$(CROSS_COMPILE)gcc
20 | AS:=$(CROSS_COMPILE)as
21 | AR:=$(CROSS_COMPILE)ar
22 | CFLAGS+=-mthumb -mlittle-endian -mthumb-interwork -DCORE_M3 -fno-builtin -ffreestanding -DSYS_CLOCK=$(SYS_CLOCK) -DCORTEX_M3 -DFROSTED
23 | CFLAGS+=-Ikernel/unicore-mx/include -Ikernel -Iinclude -Ikernel/drivers -I. -Ikernel/frosted-headers/include
24 | PREFIX:=$(PWD)/build
25 | LDFLAGS:=-Wl,-gc-sections -nostartfiles -L$(PREFIX)/lib
26 | CFLAGS+=-mthumb -mlittle-endian -mthumb-interwork
27 | CFLAGS+=-DCORE_M3 -DBOARD_$(BOARD) -D$(ARCH) -mcpu=$(MCPU)
28 | CFLAGS+=-DCONFIG_KMEM_SIZE=$(KMEM_SIZE)
29 | CFLAGS+=-DCONFIG_TASK_STACK_SIZE=$(TASK_STACK_SIZE)
30 |
31 | # KERNEL DEBUG
32 | CFLAGS-$(KLOG)+=-DCONFIG_KLOG
33 | CFLAGS+=-DCONFIG_KLOG_SIZE=$(KLOG_SIZE)
34 | CFLAGS-$(HARDFAULT_DBG)+=-DCONFIG_HARDFAULT_DBG
35 | CFLAGS-$(MEMFAULT_DBG)+=-DCONFIG_EXTENDED_MEMFAULT
36 | CFLAGS-$(STRACE)+=-DCONFIG_SYSCALL_TRACE
37 |
38 | #PTHREADS
39 | CFLAGS-$(PTHREADS)+=-DCONFIG_PTHREADS
40 |
41 | # IPC
42 | CFLAGS-$(PIPE)+=-DCONFIG_PIPE
43 | CFLAGS-$(SIGNALS)+=-DCONFIG_SIGNALS
44 |
45 | #MPU
46 | CFLAGS-$(MPU)+=-DCONFIG_MPU
47 |
48 | #GCC Optimizations
49 | CFLAGS-$(GDB_CFLAG)+=-ggdb3
50 | CFLAGS-$(OPTIMIZE_NONE)+=-O0
51 | CFLAGS-$(OPTIMIZE_SIZE)+=-Os
52 | CFLAGS-$(OPTIMIZE_PERF)+=-O3
53 |
54 | CFLAGS+=$(CFLAGS-y)
55 | #Include paths
56 | CFLAGS+=-Ikernel -Iinclude -I. -Ikernel/unicore-mx/include/unicore-mx -Ikernel/unicore-mx/include
57 | #Freestanding options
58 | CFLAGS+=-fno-builtin
59 | CFLAGS+=-ffreestanding
60 | CFLAGS+=-nostdlib
61 | ASFLAGS+=-mthumb -mlittle-endian -mthumb-interwork -ggdb -mcpu=$(MCPU)
62 |
63 |
--------------------------------------------------------------------------------
/rules/picotcp.mk:
--------------------------------------------------------------------------------
1 |
2 | ifeq ($(TCPIP_MEMPOOL_YN),y)
3 | MEMPOOL+=-DCONFIG_TCPIP_MEMPOOL=$(CONFIG_TCPIP_MEMPOOL)
4 | endif
5 |
6 | ifeq ($(PICOTCP),y)
7 | CFLAGS+=-DCONFIG_PICOTCP -I$(PREFIX)/include -Ikernel/net/socket -nostdlib
8 | PICO_OPTIONS=CROSS_COMPILE=arm-frosted-eabi- ARCH=cortexm3 RTOS=1 PREFIX=$(PREFIX) \
9 | DHCP_CLIENT=0 DHCP_SERVER=0 MDNS=0 DNS_SD=0 \
10 | OLSR=0 SLAACV4=0 SNTP_CLIENT=0 PPP=0 TFTP=0 \
11 | AODV=0 \
12 | SIXLOWPAN=0
13 | PICO_LIB:=$(PREFIX)/lib/libpicotcp.a
14 |
15 | ifneq ($(CONFIG_PICOTCP_DEBUG),y)
16 | PICO_OPTIONS+=DEBUG=0
17 | endif
18 | ifneq ($(CONFIG_PICOTCP_LOOP),y)
19 | PICO_OPTIONS+=DEVLOOP=0
20 | endif
21 | ifneq ($(CONFIG_PICOTCP_IPV6),y)
22 | PICO_OPTIONS+=IPV6=0
23 | else
24 | CFLAGS-y:=CONFIG_IPV6=1
25 | endif
26 | ifneq ($(CONFIG_PICOTCP_IPV4),y)
27 | PICO_OPTIONS+=IPV4=0
28 | endif
29 | ifneq ($(CONFIG_PICOTCP_TCP),y)
30 | PICO_OPTIONS+=TCP=0
31 | endif
32 | ifneq ($(CONFIG_PICOTCP_UDP),y)
33 | PICO_OPTIONS+=UDP=0
34 | endif
35 | ifneq ($(CONFIG_PICOTCP_DNS),y)
36 | PICO_OPTIONS+=DNS_CLIENT=0
37 | else
38 | CFLAGS-$(PICOTCP)+=-DCONFIG_DNS_CLIENT=1
39 | endif
40 | ifneq ($(CONFIG_PICOTCP_MCAST),y)
41 | PICO_OPTIONS+=MCAST=0
42 | endif
43 | ifneq ($(CONFIG_PICOTCP_NAT),y)
44 | PICO_OPTIONS+=NAT=0
45 | endif
46 | ifneq ($(CONFIG_PICOTCP_IPFILTER),y)
47 | PICO_OPTIONS+=IPFILTER=0
48 | endif
49 | ifeq ($(LOWPOWER),y)
50 | PICO_OPTIONS+=TICKLESS=1
51 | endif
52 |
53 | PICO_OPTIONS+=EXTRA_CFLAGS="-DFROSTED -I$(PWD)/kernel -I$(PWD)/include -nostdlib -DPICO_PORT_CUSTOM $(MEMPOOL)"
54 | BUILD_PICO=make -C kernel/net/picotcp $(PICO_OPTIONS)
55 | endif
56 |
57 |
--------------------------------------------------------------------------------
/rules/userspace.mk:
--------------------------------------------------------------------------------
1 | USERSPACE=frosted-userland
2 |
--------------------------------------------------------------------------------
/scripts/frosted-dev-setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | printf "\nSetting up Frosted dev env...";
4 | path="$(pwd)";
5 |
6 | cd ~;
7 |
8 | mkdir frosted-dev;
9 | cd frosted-dev;
10 |
11 | sudo apt-get install build-essential cmake libusb-1.0 libusb-1.0.0-dev git screen
12 |
13 | wget http://archive.trexotech.com:8081/arm-frosted-eabi-latest.tar.bz2;
14 | tar xjf arm-frosted-eabi-latest.tar.bz2;
15 | export PATH="$(pwd)/arm-frosted-eabi/bin:$PATH";
16 |
17 | git clone https://github.com/texane/stlink.git;
18 | cd stlink;
19 | mkdir build;
20 | cd build;
21 | cmake -DCMAKE_BUILD_TYPE=Debug ..;
22 | make;
23 | cd ..;
24 | sudo cp etc/udev/rules.d/*.rules /etc/udev/rules.d/;
25 | sudo udevadm control --reload-rules;
26 | sudo udevadm trigger;
27 | export PATH="$(pwd)/build:$PATH";
28 |
29 | cd "$path";
30 |
31 | git submodule init;
32 | git submodule update;
33 | cd frosted-userland;
34 | git submodule init;
35 | git submodule update;
36 |
37 |
38 | printf " OK!\n\nFrosted dev env setup in ~/frosted-dev\n\n";
39 |
--------------------------------------------------------------------------------
/scripts/frosted-qemu-setup:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 |
4 | if [[ $- != *i* ]]; then
5 | echo "You should dot me in" >&2;
6 | exit 1;
7 | fi
8 |
9 | printf "\nSetting up Frosted qemu env...\n\n";
10 | path="$(pwd)";
11 |
12 | cd ~;
13 |
14 | mkdir frosted-qemu
15 | cd frosted-qemu;
16 |
17 | sudo apt-get install build-essential cmake libusb-1.0 libusb-1.0.0-dev git screen;
18 |
19 | wget http://archive.trexotech.com:8081/arm-frosted-eabi-latest.tar.bz2;
20 | tar xjf arm-frosted-eabi-latest.tar.bz2;
21 | export PATH="$(pwd)/arm-frosted-eabi/bin:$PATH";
22 |
23 | sudo apt-get build-dep qemu;
24 | git clone git://github.com/insane-adding-machines/qemu.git;
25 | cd qemu;
26 | ./configure --prefix="$(pwd)/../qemu-bin" --target-list=arm-softmmu;
27 | make;
28 | sudo make install;
29 | sudo chmod u+s "$(pwd)/../qemu-bin/libexec/qemu-bridge-helper";
30 |
31 | cd ..;
32 | export PATH="$(pwd)/qemu-bin/bin:$PATH";
33 |
34 | sudo mkdir qemu-bin/etc;
35 | sudo mkdir qemu-bin/etc/qemu;
36 | printf "allow br0\n" | sudo tee qemu-bin/etc/qemu/bridge.conf;
37 |
38 | cd "$path";
39 |
40 | git submodule init;
41 | git submodule update;
42 | cd frosted-userland;
43 | git submodule init;
44 | git submodule update;
45 | cd ..;
46 |
47 | printf "\nFrosted qemu env setup in ~/frosted-qemu\n\n";
48 |
49 | printf "For adding the env path autmatically, update your PATH with:\n";
50 | printf "$HOME/frosted-qemu/arm-frosted-eabi/bin\n";
51 | printf "$HOME/frosted-qemu/qemu-bin/bin\n\n";
52 |
--------------------------------------------------------------------------------
/xipfs.h:
--------------------------------------------------------------------------------
1 | #ifndef XIPFS_NULL
2 | #define XIPFS_NULL
3 |
4 | void xipfs_init(void);
5 |
6 | #endif
7 |
8 |
--------------------------------------------------------------------------------