Compare commits

845 Commits
Author SHA1 Message Date
James Sullins 29304ab8a4 add sercon (serial console) support 2012-02-16 12:53:32 -06:00
James Sullins 1a958df6d4 center menu properly 2012-01-09 05:51:57 -06:00
James Sullins 5161dd4c2e add quick opal hack 2012-01-09 02:22:47 -06:00
James Sullins e6c4f22d37 update version to 0.3.5 2011-11-27 19:13:30 -06:00
James Sullins 0eac06f976 add /boot/moboot.verbose.IMAGENAME support 2011-11-27 19:11:45 -06:00
James Sullins 3cc45d541c check image size before data-crc 2011-11-10 21:39:57 -06:00
James Sullins cf5cc42b04 fixup red/blue colors 2011-11-10 21:31:31 -06:00
James Sullins 05785b19a5 cleanup cruft in app/moboot, red to blue w/ background image 2011-11-10 21:15:06 -06:00
James Sullins c3c720b6ac set board_type, add MOBOOT_VERSION 2011-11-10 12:56:54 -06:00
James Sullins 0be67e1b88 app/moboot, lib/bootlinux: experimental ramdisk support 2011-11-02 08:37:40 -05:00
James Sullins ff838783fd initial ramdisk (payload) support 2011-11-02 08:36:25 -05:00
James Sullins 0e88c0d6f9 fix_load_file_mem: add trailing NULL 2011-11-02 08:34:03 -05:00
James Sullins 895867d50f allow key-press to disable autoboot (next) 2011-11-01 15:14:59 -05:00
James Sullins e0dcf977c4 more app/moboot stuff 2011-10-30 10:48:38 -05:00
James Sullins 9113266f9e update app/moboot - lots-o-stuff 2011-10-30 10:39:50 -05:00
James Sullins f030875b65 disable early display_init 2011-10-30 10:39:30 -05:00
James Sullins e92c2c7a5f add HANDLE_LINUX_KERNEL_ARGS, set DEBUG=0 2011-10-30 10:38:08 -05:00
James Sullins 65e2430cb6 update platform/debug - more flexible 2011-10-30 10:37:28 -05:00
James Sullins a7182f71c5 platform/rules - add display 2011-10-30 10:37:18 -05:00
James Sullins 458683f436 update platform/platform 2011-10-30 10:37:05 -05:00
James Sullins 86854fd63d update target/rules 2011-10-30 10:36:55 -05:00
James Sullins 6ea9e2978f update target/init 2011-10-30 10:36:44 -05:00
James Sullins effd0b0bb6 update target/gpio target/gpiokeys 2011-10-30 10:36:28 -05:00
James Sullins 813334df13 update platform/pmic 2011-10-30 10:36:19 -05:00
James Sullins 62e3399f4b add tools/create-umulti-sample 2011-10-30 10:36:10 -05:00
James Sullins fbdc1ae34e update lib/fs 2011-10-30 10:35:56 -05:00
James Sullins be2e61d7bb add lib/atags 2011-10-30 10:35:38 -05:00
James Sullins 2576bfc656 add lib/bootlinux 2011-10-30 10:34:48 -05:00
James Sullins 883ee18049 add lib/uimage 2011-10-30 10:34:32 -05:00
James Sullins 784c283e2e update include/dev/display, add platform/display 2011-10-30 10:33:54 -05:00
James Sullins c58d99234b update lib/gfx lib/gfxconsole lib/font 2011-10-30 10:33:29 -05:00
James Sullins b43101b3b6 add tmp/ to .gitignore 2011-10-30 10:33:04 -05:00
James Sullins 2e99501893 fix argc check 2011-10-06 23:50:22 -05:00
James Sullins f5e5ee63ea initial README file -- needs text... 2011-09-28 10:58:06 -05:00
James Sullins e1b5a9a8bf add basic fs_dirent(); mode,(cma)time in stat 2011-09-26 19:00:02 -05:00
James Sullins cc240d3589 tool to extract uImages 2011-09-25 07:58:33 -05:00
James Sullins 14a5493be1 add mkimage to build system 2011-09-24 22:22:19 -05:00
James Sullins 508c4aa481 update project rules.mk replacing aboot w/ moboot 2011-09-24 21:03:37 -05:00
James Sullins f10763a816 add app/moboot w/ sample menu 2011-09-24 20:59:20 -05:00
James Sullins 0b6c9668e3 correct subdev bounds checking, add err msgs 2011-09-24 03:10:26 -05:00
James Sullins 150f08154c update fbcon: inter-char pixel, fbcon_setpos, fbcon_set_colors 2011-09-23 19:50:55 -05:00
James Sullins 62fbcc89ec update platform iomap.h 2011-09-23 19:15:03 -05:00
James Sullins 025ebd009e update restart_device() 2011-09-23 18:34:41 -05:00
James Sullins b649709cb0 update platform iomap.h defines 2011-09-23 18:30:11 -05:00
James Sullins d8d7813a92 add scm-io, pmic to platform rules.mk 2011-09-23 18:16:08 -05:00
James Sullins b9fb329ea4 pull pmic from platform msm8x60 2011-09-23 17:13:35 -05:00
James Sullins b629077b90 pull scm-io from platform msm8x60 2011-09-23 17:12:43 -05:00
James Sullins d803de4e99 add zlib-1.2.5 (only crc32 tested, so far) 2011-09-23 16:05:52 -05:00
James Sullins 22d827972d correct target_atag_mem, remove unused funcs 2011-09-23 10:58:46 -05:00
James Sullins dfd2d6b446 add partition_get_count() 2011-09-23 10:40:15 -05:00
James Sullins d05af5fa57 add example 'getkeys:' command to fastboot 2011-09-23 04:59:38 -05:00
James Sullins 89b8299033 update target rules.mk: add gpio/gpiokeys, cleanup 2011-09-23 04:58:34 -05:00
James Sullins 84b6bbe6f0 add gpio/gpiokeys to target 2011-09-23 04:57:32 -05:00
James Sullins 32e5b3f020 add lib_bio mmc support 2011-09-22 21:29:42 -05:00
James Sullins 999ac0972f cleanup line-endings in source file 2011-09-22 21:06:16 -05:00
James Sullins c82ff92dfb pass (possible) linux kernel args to kmain 2011-09-22 16:58:15 -05:00
James Sullins fe6336ca14 pull ext2 code (back in) from git://git.newos.org/lk.git
copied ext2 code back in from git://git.newos.org/lk.git
see commit e37587a183289522de499c905a473d059c41fb64
by Travis Geiselbrecht <geist@foobox.com>
on Fri, 7 May 2010 00:25:09 +0000 (17:25 -0700)
2011-09-22 16:09:58 -05:00
James Sullins d300c65fe0 fastboot command_loop rework 2011-09-18 03:07:52 -05:00
James Sullins f3035e9039 update project makefile: DEBUG/DISABLE_MMC_DEBUG_SPEW/_EMMC_BOOT 2011-09-15 17:54:25 -05:00
James Sullins 9b7d997794 allow silencing low-level MMC debug out w/ DISABLE_MMC_DEBUG_SPEW 2011-09-15 17:52:54 -05:00
James Sullins 8589013048 update display_init: runonce/fbcon_clear 2011-09-15 17:45:44 -05:00
James Sullins 6397f6e31e revert temp fix for debugging output (SPEW define) 2011-09-15 17:02:54 -05:00
James Sullins 73791d6d58 add thread_create/thread_exit debugging output 2011-09-15 16:58:01 -05:00
James Sullins 06a4dace6d fix critical mdelay/udelay timer problem 2011-09-15 16:54:47 -05:00
James Sullins e8e22b339e fix MSM_GIC_DIST_BASE, MSM_GIC_CPU_BASE, MSM_TMR_BASE 2011-09-15 16:51:06 -05:00
James Sullins 74dfcdf587 TEMPORARY - adjust "SPEW" define to get more debugging output 2011-09-14 06:38:17 -05:00
James Sullins 9f8a6e9f99 enable FBCON (framebuffer console) with HP Touchpad 2011-09-14 06:29:15 -05:00
James Sullins 1763501ec2 disable uart_init() 2011-09-14 06:21:32 -05:00
Timothy Meade 409ac2dfff fix build (consider moving conditions to target define) 2011-09-13 01:36:51 -04:00
Timothy Meade 3c35ea6e5b fix define 2011-09-13 00:07:14 -04:00
Timothy Meade 1c3d3fc145 fix defines in msm_shared/lcdc.c for apq-touchpad 2011-09-12 23:23:56 -04:00
Timothy Meade ee523e1a49 disable LCDC_FB_ADDR define in apq-touchpad target include display.h 2011-09-12 23:09:17 -04:00
Timothy Meade a0f51365b4 replace the msm_shared lcdc.c with our version 2011-09-12 23:07:18 -04:00
Timothy Meade ed0a064511 fix framebuffer defines for touchpad-apq 2011-09-12 23:04:47 -04:00
Timothy Meade 34fbee8391 copy lcdc to apq-touchpad platform 2011-09-12 01:53:34 -04:00
Timothy Meade ce78c2e27b fix scratch memory (thanks jonpry) 2011-09-12 01:51:00 -04:00
Timothy Meade cee801753b copy apq8064 platform as apq-touchpad update target rules.mk 2011-09-12 01:32:30 -04:00
Timothy Meade 84a7fc2881 copy msm8660 display.h to apq-touchpad 2011-09-12 01:29:54 -04:00
Timothy Meade 28bbe0b4ad copy the apq8064 target to apq-touchpad and change the membase 2011-09-12 00:14:06 -04:00
Timothy Meade 54710b5daa copy the apk8064 project makefile for apq-touchpad and enable fbcon debugging (screen output) 2011-09-11 22:35:55 -04:00
Linux Build Service Account 24241036bc Merge "app/aboot: fix cmd_boot for unsigned boot images." 2011-09-06 20:31:46 -07:00
Kinson Chik 53f8d3263b reboot/mdm9x15: Adding fastboot reboot with pm8921
Using pm8921 driver on 9x15 with pm8018 since pm8018 is
a subset of pm8921 and can be reused for rebooting.

Change-Id: I556653bab13685da69fead8c67f011a9809fb3d0
2011-09-06 16:35:01 -07:00
Shashank Mittal 1f0e266734 app/aboot: fix cmd_boot for unsigned boot images.
Change-Id: Ifc1b4b5ac3cce9fb2e759ff55e5b121c80f7a795
2011-09-01 18:24:05 -07:00
Kinson Chik ea6462494e ssbi: Cleanup ssbi dependency from gpio_keypad
SSBI declarations were in the gpio_keypad files
resulting in needing to add gpio_keypad to use
ssbi for pmic functions.

Change-Id: Ic62a499a3cbd5fab9b8235e469b93103d207b20e
2011-09-01 14:10:27 -07:00
Linux Build Service Account e29aa87e47 Merge "pm8921: Clean up variable names" 2011-08-31 18:32:50 -07:00
Kinson Chik 3925c26ddb pm8921: Clean up variable names
Changing the PULL_UP defines to specify the PULL_UP
current in the variable name.

Change-Id: Ie99c50b9cab5824ddde75663e35ad97015f6e91d
2011-08-30 16:29:42 -07:00
Linux Build Service Account 897a88ebd4 Merge "mdm9x15/init: Adding system parition to 9x15" 2011-08-30 15:53:00 -07:00
Linux Build Service Account cf6ee68546 Merge "mdm9x15/atags: Passing 21mb block to kernel" 2011-08-30 14:26:59 -07:00
Linux Build Service Account 731be3d26f Merge "app/aboot: Add spport for fastboot oem device-info command." 2011-08-30 13:43:34 -07:00
Kinson Chik 9196924385 mdm9x15/init: Adding system parition to 9x15
Adding a userspace parition named system for openembedded.

Change-Id: I0f071a423292459046499c5f73f5ee77da22aa66
2011-08-30 10:49:53 -07:00
Kinson Chik 3d9ca486f1 mdm9x15/atags: Passing 21mb block to kernel
Correcting flash size to 128mb as well.

Change-Id: Id06812b247fdb2ede776b1c1c02bcf2f18529678
2011-08-29 16:12:56 -07:00
Linux Build Service Account 51b997420d Merge "[mdm9x15]: Initial support for mdm9x15 target" 2011-08-29 15:42:41 -07:00
Linux Build Service Account 320c1d85ea Merge "pm8921: Clear voltage bits before setting requested value" 2011-08-26 22:45:22 -07:00
Linux Build Service Account 56f8ccebc3 Merge "msm_shared: Remove unused timer related definitions" 2011-08-26 22:45:22 -07:00
Ajay Dudani 0ec110f219 msm8960: RAM partition table may pass the 1st tag as 256M or 512M
Support reading memory from ram partition table either way.

Change-Id: I562e833247d2d889d6ba0ba3abeda8bde864509f
2011-08-26 21:17:30 -07:00
Shashank Mittal a003228755 app/aboot: Add spport for fastboot oem device-info command.
-- Adds "fastboot oem device-info" command to read status of device tampered and unlock flag.
-- Do not set tamper fuse in TZ after recovery reset.

Change-Id: Ic3ae07879ebac9fcbb1896dd59a26897e12fe802
2011-08-26 18:13:47 -07:00
Kinson Chik 18e36337df [mdm9x15]: Initial support for mdm9x15 target
Change-Id: I0d7f2899cacacd81594c09d688bfd0e5aa0c43b6
2011-08-26 18:07:38 -07:00
Ajay Dudani bd08a1d637 msm8660: Support devices with more than 1G RAM
Currently rest of the system does not handle initialization of >1G
RAM correctly, hence just detecting >1G RAM devices as 1G RAM devices.

Change-Id: I113750d94a83fd72107e925654a57009e8536743
TODO: Update atags to pass in additional memory to kernel.
2011-08-26 13:12:29 -07:00
Linux Build Service Account f8de51b586 Merge "msm7630: Reduce system partition size by 22MB" 2011-08-26 09:08:21 -07:00
Srilakshmi Punuru fd255eab63 msm7630: Reduce system partition size by 22MB
Change-Id: I2593faa4a80fd0f85c519c71a5657b90f6907dac
2011-08-26 17:50:40 +05:30
Ajay Dudani 60b502db6d msm_shared: Remove unused timer related definitions
Change-Id: I206e1776beb8c394e01f5858b315992e6b4f9d25
2011-08-25 18:48:45 -07:00
Kinson Chik 6570ab5739 8960/mipi: Changing order of turning off display clocks
Warning appeared in dmesg in the kernel for clock_late_init
since clocks were left on during transition to kernel from lk.
Needed to turn off all branch clocks first then root and pll
phy last.

Change-Id: I21097014f4eb4a993774bb792e2580eb409dfb4d
CRs-Fixed: 301297
2011-08-24 17:59:36 -07:00
Ajay Dudani afc5b11919 pm8921: Clear voltage bits before setting requested value
Change-Id: If11ed8ed8a50c0b1011a6aec0c441c4ef7bfe57a
CRs-Fixed: 302607
2011-08-24 14:44:54 -07:00
Shashank Mittal 162244ec5c aboot: Store unlock and rooted flag on NAND and eMMC.
-- Add 'fastboot oem unlock' command.
-- Add support to store ulock and rooted flags on disk.
-- Add support to reset rooted flag on request from recovery partition.

Change-Id: I9dc5c13f69a266ff6c81cc7157b43a975fbbf9e0
2011-08-23 11:33:56 -07:00
Shashank Mittal cd98d4709d openssl/lk: Enable signed boot img check
This uses openssl to check the boot image prior
to jumping to kernel to see if it is a signed
kernel image.

Change-Id: I92927fd9317a0f701dab395cc6d39929c64340c1
2011-08-22 14:00:27 -06:00
Linux Build Service Account a10a99cc81 Merge "lk/openssl: Adding openssl to compile in lk build" 2011-08-22 12:52:59 -07:00
Aparna Mallavarapu 34144dfd4d msm7627a: Toggle power down pin of DSI client
Toggle the power down pin of DSI client on surf/ffa
before sending panel init commands.

Change-Id: I281e4f43c73773ce4ce3004349be72a60dc16ce0
2011-08-20 21:16:03 +05:30
Linux Build Service Account f0f9ce6408 Merge "msm7627a: Toggle reset pin of DSI client & power down DSI chip" 2011-08-17 11:01:23 -07:00
Channagoud Kadabi ad75f98c81 LK: Fix undefined reference when DEBUG_LEVEL is two
When Debug level is defined as more than 1 compilation fails with
undefined reference to current_time_hires. Implement current_time_hires
to fix this issue.

Change-Id: I9636928f501ac1bd75cdf424ac50c2fab844b3bc
2011-08-17 22:20:22 +05:30
Channagoud Kadabi 2199269214 msm7627a: Toggle reset pin of DSI client & power down DSI chip
- For splash screen to work on FFA , toggle RESET pin of DSI
client before sending panel init commands.
 - Ensure DSI Bridge chip is powered down during apps BL
exit so that when kernel comes up DSI client will be powered
on in a clean state.
 - Also corrected missing indentation in shutdown function.

Change-Id: If3cf4f90463379871ebf4f66b7fe0da8bf1a742f
2011-08-17 10:26:21 +05:30
Kinson Chik 2cd211fccc lk/openssl: Adding openssl to compile in lk build
This is used for verifying signed kernel.
Openssl library will be used for certificate parsing
and rsa decryption.

Change-Id: Icf0024afd8f4d8690d077b47f4b9e83cad1e4813
2011-08-12 18:18:32 -07:00
Linux Build Service Account df5ae1415e Merge "msm: Increase system ptn size by 30MB for 7627/7630/7627a targets" 2011-08-10 14:24:56 -07:00
Linux Build Service Account f220524d63 Merge "msm: Increase max flash size for 7627/7630/7627a targets" 2011-08-10 14:24:56 -07:00
Linux Build Service Account 93fde8d68d Merge "fastboot: Add support to send INFO messages through fastboot." 2011-08-09 21:41:47 -07:00
Shashank Mittal 6a5609fa22 fastboot: Add support to send INFO messages through fastboot.
Change-Id: I5eecb68688a4a7ec95d8af6ba4d6c017dd67ebd6
2011-08-09 10:43:58 -07:00
Kinson Chik 6ba6907987 openssl/lk: Removing the Android.mk files from openssl
Initial port of openssl included the Android.mk files. This
will break building android from Top level of android. Removing
the Android.mk files copied from openssl library in external.

Change-Id: I9610f2c27647b9997ac989e110e4d9c3b3cf49da
2011-08-08 12:11:13 -07:00
Kinson Chik a8fa74c31f openssl/lk: Adding openssl 1.0.0a to LK
This is the same openssl 1.0.0a in the external
folder of Android tree with Android.mk files.

Change-Id: Ie21f916d5925042c260f0640cfaec231f46cf74a
2011-08-08 12:08:38 -07:00
Aparna Mallavarapu 45869c308e msm7x27A: Enhance splash screen to support HVGA resolution
Change-Id: I8495f69e40f93638ff61a273f97b269af971ef52
2011-08-08 10:43:36 +05:30
Greg Grisco 1073a5e9c2 Clean up more warnings
Change-Id: I8fc1a0a55a421ee3dbdcb484fbea71192359471d
2011-08-05 03:45:07 -06:00
Linux Build Service Account 0c82c69f39 Merge "msm7627a: splash screen support" 2011-08-04 23:14:25 -07:00
Linux Build Service Account 5e831c4536 Merge "msm8960: Support non-interleaved memory configuration" 2011-08-04 18:00:46 -07:00
Aparna Mallavarapu f712f5e693 msm7627a: splash screen support
Change-Id: Ifa8223a71da1cb28f1b395009e430998d2c145c6
2011-08-05 00:43:43 +05:30
Linux Build Service Account dd8e189d98 Merge "[NAND]: Avoid reading bad block marker for each page" 2011-08-04 10:43:39 -07:00
Ajay Dudani ebb0b5bb01 msm8960: Support non-interleaved memory configuration 2011-08-03 18:49:43 -07:00
Trevor Bourget 0c1093789f msm8960: Correct conversion for MTP_MSM from HW-ID to machine-type 2011-08-03 12:18:26 -07:00
Channagoud Kadabi b2fb6bacc4 [NAND]: Avoid reading bad block marker for each page
Add support to prepare bad block table and use the same to
check for bad blocks before reading any page. This would
avoid calling isbad() function for each page and will be more
efficient. With current implementation we are calling isbad()
function around 2048 times for reading 8MB of boot image.

Change-Id: I9b58c43a71de6a3e42997d2f1a150f3330df33c2
CRs-Fixed: 288863
2011-08-03 22:57:51 +05:30
Srilakshmi Punuru 4cd89c4178 msm: Increase max flash size for 7627/7630/7627a targets
Change-Id: I295232e395851c1a992a7df478c75bd4b44f56b2
2011-08-02 18:53:53 +05:30
Wentao Xu 8d6150c7d3 [msm8660/LCD]: add AUO wvga panel support
Platform check added to decide which panel to turn on for splash
screen. Also changed to enable fbcon before power up the panel to
avoid a flicker.

Change-Id: I71851862f960294220df3f030b679c5694381d7d
2011-08-02 00:18:03 -06:00
Linux Build Service Account 32a9d4ff25 Merge "gitignore: Adding rule to ignore cscope files." 2011-08-01 19:52:07 -07:00
Linux Build Service Account b2028cee4c Merge "msm8960: Add Conversion for LiQUID from HW-ID to machine-type" 2011-08-01 12:06:31 -07:00
Linux Build Service Account 3b3f5d101f Merge "mmc: Cleanup mmc code and unify mbr and gpt" 2011-08-01 12:06:31 -07:00
Linux Build Service Account 98b8091814 Merge "msm8960: Enable crypto for msm8960." 2011-07-31 18:09:46 -07:00
Amir Samuelov 6a9871b204 msm8960: Add Conversion for LiQUID from HW-ID to machine-type
Add support for the 8960 LiQUID machine-type detection on the linux kernel.

Change-Id: I8ed7a5facc4de992c9d356ee4d9230d8f7df5bd7
2011-07-31 14:38:05 +03:00
Srilakshmi Punuru 75122c97e9 msm: Increase system ptn size by 30MB for 7627/7630/7627a targets
Change-Id: I11987f7820972b4f34af0288040809a933372897
2011-07-29 11:31:52 +05:30
Corey Tabaka d4c453bf57 [pc] Use cbuf lib instead of custom queue.
The facilities to manage a key buffer with non-busy waiting already
exist, so use the existing lib in the keyboard driver instead of the
custom circular queue and wait queue.
2011-07-28 13:11:13 -07:00
Corey Tabaka 42353cab89 [pc] Make platform_read_key idle on wait queue.
Fixes hack in dgetc using arch_idle. Now platform_read_key uses a wait
queue to sleep until a key is available in the key buffer, allowing the
idle thread or other threads to run. Since the idle thread gets a chance
to run, idle time accounting is now unbroken.
2011-07-28 13:11:03 -07:00
Travis Geiselbrecht 8b99c680e2 [arm] add arch_sync_cache_range
Change-Id: Id587d967dd4e9128ca130e1386325cafbeea503a
2011-07-28 13:10:14 -07:00
Travis Geiselbrecht 6111706686 [armemu] set the display params in the armemu.conf file 2011-07-28 12:36:03 -07:00
Travis Geiselbrecht d4c88e234f [armemu] read the display size from the emulator 2011-07-28 12:35:58 -07:00
Travis Geiselbrecht 95590fdef8 [scripts] update do-armemu-test to create a default block device file if it doesn't already exist 2011-07-28 12:35:50 -07:00
Travis Geiselbrecht f26b92f4c0 [scripts] spiff up buildall to report projects that fail to build 2011-07-28 12:35:44 -07:00
Travis Geiselbrecht 800410ce1f [armemu-test] turn on as much as possible 2011-07-28 12:35:37 -07:00
Travis Geiselbrecht 801509f5da [lib][text] simple library to draw static text 2011-07-28 12:35:22 -07:00
Travis Geiselbrecht 97b5382a15 [lib][tga] routines to decode Targa files 2011-07-28 12:35:15 -07:00
Travis Geiselbrecht a59792c8d7 add license file 2011-07-28 12:35:06 -07:00
Travis Geiselbrecht 99b2d1d593 [lib] simple library routines for drawing text and keeping a graphical console 2011-07-28 12:34:43 -07:00
Travis Geiselbrecht 4c68d02013 [armemu][display] add driver for the display controller 2011-07-28 12:34:36 -07:00
Travis Geiselbrecht e06c67cd59 [lib] generic graphics routines 2011-07-28 12:34:28 -07:00
Travis Geiselbrecht 84ec880ac0 [armemu] add test code for block device 2011-07-28 12:34:20 -07:00
Travis Geiselbrecht 96f6dfe9e7 [armemu] add block device 2011-07-28 12:34:10 -07:00
Travis Geiselbrecht e8560831c3 [main] add init routines for fs and bio layer, will move to better spot later 2011-07-28 12:34:02 -07:00
Travis Geiselbrecht f86c43c65d [lib][fs] simple file system layer 2011-07-28 12:33:30 -07:00
Travis Geiselbrecht 84aa16cd8c [stdlib] add countof() 2011-07-28 12:33:19 -07:00
Travis Geiselbrecht b29c3ba306 [lib][bcache] add a simple block device cache 2011-07-28 12:32:59 -07:00
Travis Geiselbrecht 2dc9c970d7 [lib][partition] add simple block device partition scanner (MBR only) 2011-07-28 12:32:51 -07:00
Travis Geiselbrecht 5248673962 [lib][bio] add simple block io layer 2011-07-28 12:22:51 -07:00
Travis Geiselbrecht f6e2207713 [error] add some more ERR_ defines 2011-07-28 12:22:11 -07:00
Ajay Dudani c713ab89e9 [arm] fix problem with gcc 4.4 to ensure the boot code is in the binary
seems that gcc 4.4 or the newer binutils likes to put linker generated
shims first in link order. Tweak the boot code to use a special section
that is ordered first by the linker script.

Conflicts:

	arch/arm/crt0.S

Change-Id: Ib38697ce3de375965f607fd17c56bfc16b7774e1
2011-07-28 12:13:32 -07:00
Travis Geiselbrecht 12403e3c6b [kernel] add some documentation 2011-07-28 12:13:18 -07:00
Travis Geiselbrecht e74d63dd6e [armemu] fix the armemu build by adding timer routine and default config file 2011-07-28 12:13:08 -07:00
Travis Geiselbrecht 5eaef67b02 get the sam7ex256 platform building again 2011-07-28 12:12:54 -07:00
Travis Geiselbrecht 78d0e6caf6 [make] make the spotless target not depend on anything 2011-07-28 12:12:44 -07:00
Ajay Dudani ca0b6a2d2f [arch] factor out the debug_cycle_count to arch specific code
Conflicts:

	arch/arm/ops.S

Change-Id: Id0d9baa3e669cc59822819c797ce913dba1606d6
2011-07-28 12:11:57 -07:00
Travis Geiselbrecht 2ce7b9713b [omap5912] use the cbuf to do proper blocking getc 2011-07-28 12:08:48 -07:00
Travis Geiselbrecht 9e60486c32 [lib][cbuf] simple circular buffer implementation 2011-07-28 12:08:38 -07:00
Travis Geiselbrecht dbc2c68f17 [platform] fix the dgetc signature problem 2011-07-28 12:08:16 -07:00
Travis Geiselbrecht beb8d43aed [heap] bring heap debugging stuff from external source 2011-07-28 12:06:57 -07:00
Travis Geiselbrecht 671cb79488 [kernel] sync with external source. support for dynamic timer
Change-Id: I87d3c87a7a046413975108f93be63fa5a5999636
2011-07-28 12:06:21 -07:00
Travis Geiselbrecht 9045c06019 [kernel] dynamic timer support from external sources 2011-07-28 12:04:51 -07:00
Travis Geiselbrecht 28da92a61f [debug] change the dgetc signature to match external sources 2011-07-28 12:04:36 -07:00
Corey Tabaka d890c35378 Fixed typo in pci dump message. 2011-07-28 12:04:26 -07:00
Corey Tabaka 4030150f51 Fixed a latent bug due to an erroneous reg spec. This would have gone undetected unless edi was clobbered between the bug and the previous asm block. 2011-07-28 12:04:19 -07:00
Corey Tabaka ad21b8d1f1 Minor cleanup and a hack to idle the cpu in getc loops. 2011-07-28 12:04:09 -07:00
Corey Tabaka b0bd183e7f Added support for PCI config space read/write via PCI BIOS. Added some PCI commands to query/modify config space and enum devices. 2011-07-28 12:03:58 -07:00
Corey Tabaka b3f6caccf7 Reorganization to better fit platform/target conventions. 2011-07-28 12:03:47 -07:00
Corey Tabaka 7e9d615a2f Added check for compiler support of -fno-stack-protector and changed toolchain prefix to i386-elf- for x86 port. 2011-07-28 12:03:37 -07:00
Corey Tabaka 79382bc0a6 Cleaned up x86 platform memmap defs. Fill in later as needed. 2011-07-28 12:03:27 -07:00
Corey Tabaka 84697244f1 Initial x86 port 2011-07-28 12:02:54 -07:00
Kinson Chik f1a4351fed mmc: Cleanup mmc code and unify mbr and gpt
Move mbr code to partition parser and use a common
struct for both partition table types. Moving partition
related functions and defines to partition_parser from
mmc.

Change-Id: I9726b5a79817f98f86a7932a081c0aba311e3836
2011-07-28 11:58:05 -07:00
Shashank Mittal 1fcde7aaba msm8960: Enable crypto for msm8960.
-- Add support for crypto4 engine
-- Enable crypto clk only when crypto driver is used.
Change-Id: Ie50c259ae6e6090782d196af89b3a22776f88913
2011-07-27 18:47:00 -07:00
Shashank Mittal 3890b107bb gitignore: Adding rule to ignore cscope files.
Change-Id: I2f7c9d0ccb80e0446ffee0360c5bc6d3e4e54111
2011-07-27 13:45:57 -07:00
Linux Build Service Account 0a81a321a8 Merge "Clean up more warnings in lk code" 2011-07-27 07:42:03 -07:00
Linux Build Service Account 23b9de5a73 Merge "arch/arm: Add dsb() function for ARMv6 and ARMv7 devices." 2011-07-26 12:21:57 -07:00
Greg Grisco d2471ef677 Clean up more warnings in lk code
Change-Id: I71eb3f1730ae0c80ec4d0da12a5b5755bc9f5614
2011-07-26 10:28:56 -07:00
Linux Build Service Account 4f378133e3 Merge "msm7627_surf: Pass complete memory given by NONHLOS to kernel via atag" 2011-07-26 06:01:18 -07:00
Linux Build Service Account 6f7f81d5a1 Merge "Build:use is-android-codename instead of is-flavor" 2011-07-26 01:31:56 -07:00
Shashank Mittal 97d0f09096 arch/arm: Add dsb() function for ARMv6 and ARMv7 devices.
Change-Id: If3e8ca21138352dc57860d39000dbf93c6406b7d
2011-07-25 15:16:45 -07:00
Channagoud Kadabi d2adce273f msm7627_surf: Pass complete memory given by NONHLOS to kernel via atag
NON-HLOS passes correct RAM partition table, so remove fixes added
to correct partition table and pass the complete memory to kernel

Change-Id: If257ed2a053fe253f13383fbb1d4b550ca83c148
2011-07-25 14:42:32 +05:30
Ajay Dudani 6cdbd7cc0f msm: Remove obsolete targets
Prune files related to obsolete msm target configurations.

Change-Id: Idcd9bb5b3195f040ceb6956b9ee103493baa4a11
2011-07-23 23:18:13 -07:00
Kinson Chik ce306ffe9f target init.c: Moving displaying of splash before aboot_init
Moving the display of the lk splash screen to be earlier
than aboot_init and placed in the target specific init.c
files.

Change-Id: Id21c5fd580b24968e332ab6e270a28264fb3e706
2011-07-23 18:53:09 -07:00
Amol Jadi e67872e27c apq8064: Initial support
Change-Id: I98dc5d4d3e3270e1896375a31a3fbe1abbc10773
2011-07-23 17:57:46 -07:00
Greg Grisco 6e75477e02 Allow MBR/EBR partition to be flashed
Flash the partition via "fastboot flash partition <filename>".  Code
will detect the type of image, either MBR/EBR, GPT, or GPT backup.
Flash of GPT and GPT backup not yet implemented.

Change-Id: Ib5a847368c43079897f7906043a0cdf9ee153c3d
2011-07-23 17:57:19 -07:00
Shashank Mittal 395032624b msm8960: Add support to shutdown device.
Add support to shutdown target after configuring PM8921.

Change-Id: I7e2173fc1e46d8f2c6780f1bb0765f8153a2afa9
2011-07-23 17:56:53 -07:00
Ajay Dudani 35f686f788 Revert "[qsd8250]: Add usb charging support in LK bootloader."
This reverts commit 7f5b901386.

Conflicts:

	app/aboot/aboot.c
	platform/msm_shared/hsusb.c
	platform/msm_shared/hsusb.h
	platform/msm_shared/proc_comm.c
	target/init.c
	target/msm7627_ffa/init.c
	target/msm7627_surf/init.c
	target/msm7630_surf/init.c
	target/qsd8250_ffa/rules.mk
	target/qsd8250_surf/rules.mk

Change-Id: Icf5e1ba4772cfbd63e036f09388effc2f9d50e76
2011-07-23 17:56:25 -07:00
Amol Jadi aeda4e6548 msm: cleanup timer code
Moves platform dependent code to platform dirs.

Change-Id: I003d40d807932643a1c1c75f6199b972c89eb4c5
2011-07-23 17:55:24 -07:00
Linux Build Service Account 2411981d56 Merge "msm7627a: Update cache size to be 8M for 8 bit bch ecc NAND" 2011-07-23 17:18:17 -07:00
Linux Build Service Account dd17d1e2c1 Merge "init: Turn off backlight when splash is disabled" 2011-07-23 16:37:58 -07:00
Linux Build Service Account c24e6e18c9 Merge "platform/mipi_dsi: (cleanup) separating mmss and mdp from dsi" 2011-07-23 16:37:58 -07:00
Ajay Dudani efb709f9ec msm8660_surf: Increase scratch space to allow flashing larger images
Change-Id: Id70f3b22498b2abceb545e5dd24d0d758bac66b2
2011-07-23 07:37:58 -07:00
Channagoud Kadabi 500afb7d7f msm7627a: Update cache size to be 8M for 8 bit bch ecc NAND
As the no of pages per block is doubled for 8 bit bch NAND
increase the cache size accordingly. This is required for
recovery on 8 bit bch ecc NAND otherwise kernel fails to
mount cache partition.

Change-Id: I9786706bce0acddd3836f8ee9ccff8a828c3cfec
2011-07-23 02:26:16 -06:00
Linux Build Service Account 4d84d3e4f8 Merge "msm: Move modem-up dependency to target specific code." 2011-07-22 18:06:42 -07:00
Kinson Chik c1ad9468df init: Turn off backlight when splash is disabled
Currently backlight always turns on regardless if the splash
screen enabled flag is set or not. Now it will not be turned
on when splash is disabled.

Change-Id: I237358367ed9198db0c57b7eefcd614800077a74
2011-07-22 15:06:12 -07:00
Kinson Chik fe93103d91 platform/mipi_dsi: (cleanup) separating mmss and mdp from dsi
seperating mmss clk settings and mdp settings from the
msm_shared mipi_dsi.c file. Clocks will be done in acpuclock.c
Mdp settings will be done in mdp4.c file. Registers bases
moved to iomap.

Change-Id: I51c27db88b9328cb9484be5de4aeb4376cca0cc2
2011-07-22 14:04:06 -07:00
Satya Durga Srinivasu Prabhala d92dc60433 Build:use is-android-codename instead of is-flavor
Change-Id: I3952948448cb7e213b21715dee520ffcf99f4a38
2011-07-22 14:28:02 +05:30
Kinson Chik f91907f2b7 msm8960: Optimize delays for display splash
Change-Id: Icd997a82764173a73919fdefc1a987cf423a7998
2011-07-21 16:50:38 -07:00
Amol Jadi 2dfe339962 msm: Move modem-up dependency to target specific code.
Change-Id: Iaccc44eed198013f7ce8b8464570397771d0c77c
2011-07-20 15:40:56 -07:00
Linux Build Service Account 46d28982b2 Merge "msm7627a: Generate signed unified header in secure-boot for 7x27A" 2011-07-19 23:58:25 -07:00
Linux Build Service Account 3add772584 Merge "build: standardize BUILD_ID featurization" 2011-07-19 23:09:38 -07:00
Amol Jadi db1edb3d5f msm_shared: Move qgic code to msm_shared
QGIC is shared across multiple platforms and should reside
in msm_shared instead of duplicating code for all platforms.

Change-Id: If879192af552ec433da07c4c998bc62cad123c27
2011-07-19 13:21:04 -07:00
Channagoud Kadabi edc1f5d82d msm7627_surf: Fix key mapping issues for surf & ffa
Target failed to enter fastboot mode due to key
mapping differences between surf & ffa. Device enters
to recovery mode when "B" is pressed on FFA instead
of fastboot. Add key layout for ffa and initialize
keypad based on machine ID to fix the issue.

CRs-Fixed: 296976

Change-Id: Idc79dc8cf4550406a39b80f1015776ca3f6bdaca
2011-07-19 20:32:20 +05:30
Satya Durga Srinivasu Prabhala 1b8189a1ba build: standardize BUILD_ID featurization
CRs-fixed: 287594

Change-Id: Id553e01da6da24a718bce24a4a8a357d64598d09
2011-07-19 13:48:33 +05:30
Aparna Mallavarapu 5097b53031 msm7627a: Generate signed unified header in secure-boot for 7x27A
Change-Id: Ib68e16cc230027db6efcfa9a94c38dc1b694668d
2011-07-18 17:17:37 +05:30
Amol Jadi 822545696f msm_shared/mmc: cleanup mmc clock
Moved platform specific code to platform files.

Change-Id: Id12247e6ab7619de86715f0241f56ba8f24ff1ec
2011-07-15 22:34:14 -06:00
Shashank Mittal 6df1607be7 msm8660: Add support to shutdown the device in case of RTC alarm.
Change-Id: Idb0d42b2e7bc662d608edc6eb4eb41ebbf80d244
2011-07-15 21:17:15 -06:00
Linux Build Service Account 6f0c4ef760 Merge changes Iee22366b,Ie07e87f0,Iee9daddf
* changes:
  msm8960: Configure MMU to enable caching.
  msm8x60: Configure MMU to enable caching
  arch/arm/mmu: Update MMU implementation for ARMv7 architecture.
2011-07-15 20:13:07 -07:00
Amol Jadi da055740f2 msm8960: Configure MMU to enable caching.
Change-Id: Iee22366b61f8009ae93d7967d4231bb22b7a83b1
2011-07-15 16:07:46 -07:00
Amol Jadi 4421e65170 msm8x60: Configure MMU to enable caching
Change-Id: Ie07e87f00d3bc6fd2ebe4348427453fba46b8395
2011-07-15 16:05:23 -07:00
Amol Jadi 9ef9b73933 arch/arm/mmu: Update MMU implementation for ARMv7 architecture.
- Also updates the interface so platform specific code can setup
  MMU as needed for each platform with appropriate memory types
  and cache properties.

Change-Id: Iee9daddf5070f21d278339417e4ff71a5b7ca8d8
2011-07-15 15:55:51 -07:00
Chandan Uddaraju d25b3a4ce7 msm_shared: Add backlight control commands for Novatek DSI panel
For the new reworked Novatek panels, the backligh is controlled
by sending DCS commands to the panel. Add commands to
enable/control panel backlight.

Change-Id: If51f2f1f150bc65e07f898e534603c9495888910
2011-07-15 15:49:04 -07:00
Linux Build Service Account 9f179285e7 Merge "msm8960: Enabling splash screen for lk" 2011-07-14 19:17:32 -07:00
Kinson Chik e5c9343f22 msm8960: Enabling splash screen for lk
This enables splash screen support in lk for mipi
toshiba mdt61 panel.

Change-Id: Ieb9fcde096aa8c8e55a3ceb88f2fd7513ca7187e
2011-07-14 15:36:30 -07:00
Linux Build Service Account 98c31bb540 Merge "msm8960: Add support for SDRAM without bus specific information" 2011-07-14 14:41:07 -07:00
Linux Build Service Account 2b9890877e Merge "msm_shared: gsbi cleanup" 2011-07-13 22:52:13 -07:00
Ajay Dudani e495d1eb21 msm8960: Add support for SDRAM without bus specific information
msm8960 memory is described with new category type which does not
describe the specific bus related information.  Update ram partition
table check to pass memory to Linux kernel accordingly.

Change-Id: Ie3a5222dcb36e6889a8f3b3966278e0921c2fd75
2011-07-13 20:34:53 -07:00
Linux Build Service Account 9120c89766 Merge "[msm8x60]: Add PM8058 battery alarm support" 2011-07-13 20:33:10 -07:00
Amol Jadi c52c8a3f8a msm_shared: gsbi cleanup
Clean up gsbi and gsbi based uart, i2c code.

Change-Id: I900d204c0a736aa6617d40646ed8a4dd70e78bcb
CRs-Fixed: 293016
2011-07-13 18:53:11 -07:00
Linux Build Service Account da01139096 Merge "msm_shared/rules.mk: removing ifneq in the rules.mk" 2011-07-13 09:30:26 -07:00
Greg Grisco d625055fcc Clean up warnings in lk code
Change-Id: I05b3a6cf07cde7e60586b1816c2f1279f64f5cf4
2011-07-12 23:21:49 -06:00
Kinson Chik f910f9e0ef msm_shared/rules.mk: removing ifneq in the rules.mk
Changing all ifneq to ifeq for each target.

Change-Id: I14f5193978e0ad6072035425c09cfefcf29e3043
2011-07-12 16:04:24 -07:00
Subbaraman Narayanamurthy d8b7afc7da [usb]: Add support to enter test mode
For eye diagram test, USB has to be put in test mode on TEST PACKET
from HSET tool.

CRs-Fixed: 295909
Change-Id: I260753d831065e8b3876d7b95672633e6f881fb2
2011-07-12 12:44:47 -07:00
Linux Build Service Account ab41594c26 Merge "msm7627a: Modify the signed Image format for 7x27a." 2011-07-10 10:51:36 -07:00
Ajay Dudani be7733b568 msm8960: Determine usable memory for kernel based on ram partition table
Use part of EBI1 CS0 and all of EBI1 CS1 memory for kernel.
Part of EBI1 CS0 gets used for other periperals outside of kernel.

Change-Id: Ie4964160f594a723f378a244c77ae1f51894add2
2011-07-07 20:51:57 -07:00
Aparna Mallavarapu 079d7c2224 msm7627a: Modify the signed Image format for 7x27a.
Secure-boot requires the [RAW-IMAGE][SIG][CERT-CHAIN] format
for flashing the singed appsboot.mbn.

Change-Id: I430186274960632e59468957997e70dd3a0462dc
2011-07-06 17:31:09 +05:30
Ajay Dudani 27871259e9 Revert "[msm7630/DMM] : Reserve EBI-1 memory as unstable."
This reverts commit b26c956260.
2011-07-05 12:23:59 -07:00
Aparna Mallavarapu d5ebc8fb7f msm7627a: Ignore the extra 1MB of IRAM being passed by NON-HLOS
Change-Id: I46bf458c22e4171991eaa0bb3ed0843a040d7a6c
2011-07-04 13:49:19 +05:30
Linux Build Service Account 4e4ba4c999 Merge "msm8960: Fix restart reason address." 2011-07-03 01:08:15 -07:00
Linux Build Service Account 23a884ba7f Merge "pm8921: Change log level from info to critical" 2011-07-03 01:08:15 -07:00
Ajay Dudani 62a0d3e67c msm8660: Add support for Dragonboard variant
Change-Id: I7142d1cf69f7c53165095c6270d9e84c9513f293
2011-07-01 14:29:02 -07:00
Ajay Dudani e28a60708d aboot: Use kernel & ramdisk physical addresses from boot.img header
Drop dependency on target defined/hardcoded kernel & ramdisk physical
addresses.  Use ones defined in boot.img header instead.

Change-Id: Ieac73cc8101cd0c92bc5eb654e1993278de5dfc6
2011-07-01 14:01:47 -07:00
Subbaraman Narayanamurthy 0e445b0159 [lk]: Add support for SSD implementation of image upgrade
Recovery sets bootloader messages in MISC partition as part of SSD
process.For NAND target, we set cookie in FOTA partition. For eMMC
target, recovery creates cookie file. We read the SSD update status
from the early boot chain and send it to recovery to finish up the
process.

Change-Id: I5d0d2dbe06bf1773fe9daaf6904f8e59a4c30ad4
2011-06-30 11:09:09 -06:00
Channagoud Kadabi 690515d2d6 [msm_shared/nand]: Fix RAM address corruption
Wrong EXE command to NAND controller corrupted the RAM address, which
in turn caused issue in audio functionality. Fix the read reg function
to pass right commands to NAND controller.

Change-Id: I2e5a12540de8db877b84ba1f3072a27e2ecaa0de
2011-06-29 21:50:27 +05:30
Kinson Chik ef7b943fed pm8921: Change log level from info to critical
Changing the log level from info to critical for gpio_config
as they are errors and should always be reported.

Change-Id: If10d415ed494a655a67793438240c3845aaa2b50
2011-06-29 08:49:55 -07:00
Shashank Mittal 0207df7398 msm8960: Fix restart reason address.
Change-Id: I59aa3d3ad0595f8fdfaaaa5fe475c5041f78b9f4
2011-06-29 08:59:03 -06:00
Linux Build Service Account 8685492464 Merge "msm_shared/mmc: Reduce the delay in sending CMD1" 2011-06-29 07:53:11 -07:00
Linux Build Service Account 1dbb17db61 Merge "pm8921: ldo config" 2011-06-29 07:53:11 -07:00
Linux Build Service Account 1863a355a3 Merge "include/bits: Fix BIT macro." 2011-06-29 07:53:11 -07:00
Shashank Mittal 6239b16894 msm8960: Fix reboot command on CDP.
On CDP watchdog bark is not working to reboot the device.
So try to do PSHOLD first to reboot the device.

Change-Id: I0447d3b003004e43ec5a9508c87ca227416c56d5
2011-06-28 18:03:49 -07:00
Amol Jadi 60a5597455 pm8921: ldo config
Adding functionality to program LDO through PM8921.

Change-Id: I83fd289ee51aca33f17df709666c9a630cc80267
2011-06-28 16:21:45 -07:00
Shashank Mittal efb6c972f1 include/bits: Fix BIT macro.
Fix BIT macro to return a number with only requested bit set.
Renamed existing BIT macro to BIT_GET

Change-Id: I6e1ea5fa99be65950ec3d885579ad8d2b591f102
2011-06-24 17:12:57 -07:00
Subbaraman Narayanamurthy 8c7cd22c3a [msm8x60]: Add PM8058 battery alarm support
Adding PM8058 battery alarm APIs to help charging.

Change-Id: If296017927497b0b1c5575ae846bc99d6053f791
2011-06-24 12:54:22 -07:00
Channagoud Kadabi 9090b3b845 msm7627a: Pass complete memory given by NONHLOS to kernel via atags
NON-HLOS passes correct RAM partition table, so remove fixes added
to correct partition table and pass the complete memory to kernel

Change-Id: I63c37a751e98a812871acc9355e3781046f4cea4
2011-06-23 22:54:09 +05:30
Linux Build Service Account 2603f134c8 Merge "[msm8x60/pmic]: Add LCD brightness control API for PM8058" 2011-06-16 04:31:48 -07:00
Linux Build Service Account 34ffe7c087 Merge "[msm_shared/i2c_qup]: Fix error in using wrong base address" 2011-06-16 04:31:48 -07:00
Linux Build Service Account 8d574f84bb Merge "dev/keypad: Removed unnecessary scans for detecting key press event." 2011-06-16 02:14:55 -07:00
Amol Jadi 58373d43a7 msm_shared/mmc: Reduce the delay in sending CMD1
- Spec does not specify any necessary delay between sending
  multiple CMD1. Reduce it just enough to count the 1sec
  restriction on the MMC card to come out of busy state.

Change-Id: I03aa19e4d409dd17b8603f67bfa69d8c7006e966
2011-06-16 02:31:39 -06:00
Linux Build Service Account 9b5b72691e Merge "msm7x27a: Enables support for eMMC boot." 2011-06-14 02:51:14 -07:00
Subbaraman Narayanamurthy 8f1ffa5253 [msm8x60/pmic]: Add LCD brightness control API for PM8058
Adding LCD display brightness control API by configuring PWM in PMIC.

Change-Id: I4d4103eba315cd3d4986032f7355cc9a08d176ac
CRs-Fixed: 287902
2011-06-13 13:17:01 -07:00
Linux Build Service Account 838465636e Merge "msm8960: Adding backlight support to lk" 2011-06-10 21:27:58 -07:00
Subbaraman Narayanamurthy dcc8e933d4 [msm_shared/i2c_qup]: Fix error in using wrong base address
Change-Id: I6116d4b86c4e707fd1f1526de95b1c380ee8a4d7
CRs-Fixed: 289106
2011-06-10 18:35:09 -07:00
Aparna Mallavarapu 5a83b2a618 msm7x27a: Enables support for eMMC boot.
Change-Id: Ib9f7b313ed17d84c50982d77adf9b8ef0bd1ddc6
2011-06-10 20:15:01 +05:30
Linux Build Service Account 5795af99ce Merge "mmc/aboot: Adding GPT parser for appsboot" 2011-06-09 23:37:09 -07:00
Kinson Chik 1ac45ceb8d msm8960: Adding backlight support to lk
Adding support to turn on backlight for lk
through pm8921 GPIO. Turning backlight on
by default for lk.

Change-Id: I97171c9f0e1d18053bb2d45b00bccb7c5ca4804d
2011-06-09 18:23:23 -07:00
Linux Build Service Account 02843f9521 Merge "dev/pmic: adds pm8921 gpio config api" 2011-06-09 13:02:05 -07:00
Kinson Chik 66552a8cf9 mmc/aboot: Adding GPT parser for appsboot
Initial commit for adding a GPT parser for Guid Partitions.
This only adds the functionality and enables
GPT to be parsed and as well as MBR format.

Change-Id: I9a85926cc0f4503cd169f8eaed867f1f2df97598
2011-06-09 11:33:09 -07:00
Amol Jadi 3570f9ddf7 dev/pmic: adds pm8921 gpio config api
Change-Id: I995b23be5b45d75a518fc1f010aeeefba692124b
2011-06-09 10:13:48 -07:00
Linux Build Service Account ef7dca456f Merge "LK: Add 8bit BCH ECC Nand support." 2011-06-09 02:48:38 -07:00
Channagoud Kadabi 1eb82c6d91 LK: Fix atags issue for EMMC boot on 7x27
- As the ram partition size coming from modem are not rounded to
MB, kernel fails to boot if the partition size passed through atags
are not aligned to megabyte size, added fix to round down the partition
size to MB before passing to kernel.

 - Modem passes correct RAM partition table, so remove fixes added
to correct partition table.

 - RAM partition table passed by modem consists of 2 partitions
1.parition to be used by apps & 2. A 1MB partition which is base
of QCSBL.At present we are not able to use QCSBL partition so ignore
the partition size which are less or equal to 1MB

Change-Id: I053ed58de76871a2d646f8c449b7fed1d949c7af
2011-06-08 23:29:49 +05:30
Channagoud Kadabi 404a7066be LK: Add 8bit BCH ECC Nand support.
Change-Id: I84277d6d3fd9021a3dcf1e5711827de05d4288d3
2011-06-08 19:11:17 +05:30
Linux Build Service Account ada68ef8b9 Merge "msm8960: Pass complete EBI memory available to kernel as memory tags" 2011-05-27 11:48:06 -07:00
Amol Jadi 57abe4cd2e msm8960: set the boot_done flag in pm8921 on fastboot
Change-Id: I9317c035cf2b13f3e29d4b43c0831060001008fd
2011-05-24 19:08:56 -07:00
Amol Jadi f2f4560575 dev/pmic: Adds PM8921 driver
- minimal functionality to init and set the boot_done flag.

Change-Id: Iaed0fadc3ede3fdaf9877804ce38fc2fb40bb9e3
2011-05-24 19:08:46 -07:00
Amol Jadi db7845319c dev/keypad: Removed unnecessary scans for detecting key press event.
- Reduces boot time spent in LK.

Change-Id: I62f289bd46dcd18ed1a42aeeceb7480f2241be6d
2011-05-23 12:58:40 -07:00
Linux Build Service Account 624255324f Merge changes I89a64cd1,I1ebb4766
* changes:
  msm: mmc: Fix type casting error when looking up large partition offset
  aboot: Report error if sparse image is flashed incorrectly
2011-05-18 20:50:23 -07:00
Ajay Dudani 000eedd9aa msm: mmc: Fix type casting error when looking up large partition offset
CRs-Fixed: 288481
Change-Id: I89a64cd1acb49d576e44904cb4acdc00dc413def
2011-05-18 19:07:16 -07:00
Subbaraman Narayanamurthy f7940e7045 [msm8x60/pmic]: Add LDO defines for PM8058
Change-Id: Ieb6fb064ea332311b3540fade3e8704d23314eaf
CRs-Fixed: 285190
2011-05-18 13:14:13 -07:00
Ajay Dudani 0c6927b63e aboot: Report error if sparse image is flashed incorrectly
Change-Id: I1ebb4766ee441c1198604ea3045ac2d6448868bd
2011-05-18 11:12:16 -07:00
Shashank Mittal 5d564b6f87 msm7x27a: Remove code to enable PLL4.
On 7x27a we are not using PLL4 for 600MHZ ACPU frequency.
So removing this code to save power during bootup.

Change-Id: Ic30a3876f4455f5867e421ad4dc5b48c1bd59732
2011-05-16 17:45:01 +05:30
Amol Jadi 64c58c19f7 msm8960: updated machine type detection.
Change-Id: Ie66f8ab8e4e94ee2f0540d6b1089113b6d768d24
2011-05-15 01:33:12 -06:00
Ajay Dudani 3bb24e374c msm8960: Pass complete EBI memory available to kernel as memory tags
Linux Kernel now gets 141M + 768M as usable memory regions.

Change-Id: I2481d0999dce8b0484b6d9505d7b104dbaf133d2
2011-05-13 13:38:16 -07:00
Ajay Dudani b06c05faee msm: Reduce logging level of some messages from INFO to SPEW
Enable debug level 1 logging for msm8960

Change-Id: Ifab74b8444bdf8ac79e1d2aac62ac93d73b1dd2c
2011-05-12 14:46:10 -07:00
Ajay Dudani ab18f02ad6 aboot: Fix type casting when flashing images to mmc for sparse images
Change-Id: I4f7efee5b0107a10873d0d44acc7bb1b77f821d8
2011-05-12 14:39:22 -07:00
Ajay Dudani 12091e2fc0 msm8960: Use emmc product id as unique usb serial number
Change-Id: I6dd4bccd0f6aec24340ba9225cad07b45345f9f0
2011-05-12 12:16:34 -07:00
Linux Build Service Account 6ea1e3451e Merge "msm7627a: Increase recovery partition size to 10MB" 2011-05-12 06:13:50 -07:00
Linux Build Service Account 614db415a2 Merge "msm7x27a: Fix acpuclock code for 7x27a." 2011-05-12 03:05:20 -07:00
Aparna Mallavarapu 84d39f3127 msm7627a: Increase recovery partition size to 10MB
Change-Id: I5c9d4f7deeca2c0a572e06b6bd069cbb5291da9e
2011-05-12 03:23:15 -06:00
Linux Build Service Account 250e5ce76e Merge "msm7627a: Increase system partition size to 120MB" 2011-05-12 02:18:37 -07:00
Shashank Mittal 302a6330a4 msm7x27a: Fix acpuclock code for 7x27a.
In 7x27a, A11S_CLK_SEL register supports new settings. While
configuring AHB_CLK_DIV and CLK_SEL_SRC, other bits should remain
unaffected.

Change-Id: Ic258fe5f28302ff9b47db6515359dc2dafcfcec9
2011-05-12 14:28:48 +05:30
Kinson Chik kchik@codeaurora.org d120bb23ae fastboot/sparse: Overflow for sparse images larger than 5gb
Type casting causing overflow of data address.

Change-Id: I5140be4200023d3dbd08342182256c072cbc8f93
2011-05-11 11:23:42 -07:00
Shashank Mittal daef9e5718 msm8960: Increase max flash size.
Change-Id: I47f992af4359d3c6ff69b45ce982944be902cb30
2011-05-11 09:30:45 -07:00
Srilakshmi Punuru 9bb6f8b95e msm7627a: Increase system partition size to 120MB
Change-Id: I75f335574f0ede838acfd65ee74b912323e4cc92
2011-05-11 09:16:55 +05:30
Amol Jadi f30a803656 msm8960: keyboard fix
Change-Id: If439ed12c9cf3514610aea3b7415bd8a8708255d
2011-05-10 19:25:01 -07:00
Linux Build Service Account 6465bed7e8 Merge "msm8960: usb fix" 2011-05-10 19:06:32 -07:00
Linux Build Service Account 1435c1b539 Merge "msm7627a: Fix misc and persist nand partition size" 2011-05-10 18:15:50 -07:00
Amol Jadi 8b7f4e7efe msm8960: usb fix
Change-Id: I1c92fb6698441f8e10af0283260f3203f0a9b2ea
2011-05-10 13:43:17 -07:00
Shashank Mittal ed17773709 msm:8960: msm8x60: Fix clocks for usb, uart and mmc.
Change-Id: I54519ae7fb557eacdd4d744b5fd3b8d5c341e6d3
2011-05-07 18:17:50 -07:00
Kinson Chik kchik@codeaurora.org da29b1e973 aboot/sparse: Fix default case and flashing for sparse parsing
For don't care blocks the total_block needs to be updated as
this is used for the offset to write on emmc/mmc. Default
case is also missing the default tag and never enters
when an unrecognized type is detected.

Change-Id: Id96e0846e32f5479abb263df7fe9b771db1ff64b
2011-05-07 15:53:09 -06:00
Linux Build Service Account 7d13e2b403 Merge "msm8960: Fix memory address and atags." 2011-05-07 02:48:26 -07:00
Linux Build Service Account 1f96ee0fc9 Merge "msm8960: Add machine ids for CDP, MTP, APQ and Fluid." 2011-05-06 23:33:01 -07:00
Shashank Mittal d67508a166 msm8960: Add machine ids for CDP, MTP, APQ and Fluid.
Makes CDP as default platform.

Change-Id: I59f9813ce66d9e053321be37834651a16b4af53a
2011-05-06 19:19:37 -07:00
Linux Build Service Account 20ef1fe8d0 Merge "aboot: Correcting spelling mistake." 2011-05-06 18:10:37 -07:00
Shashank Mittal 0427627414 msm7627a: Fix misc and persist nand partition size
Update partition size to be 4M to yaffs block size limitation.

Change-Id: I48174df5926adf91fcf8cfa6ebeed94391311227
2011-05-06 15:13:45 -07:00
Kinson Chik kchik@codeaurora.org 82e4ae6ef0 aboot: Correcting spelling mistake.
"Invaled" should be Invalid.
"heador" should be header.
Change-Id: Iea6d96cacac42c9ee7896fc21325d11fd1217cb7
2011-05-06 15:55:36 -06:00
Amol Jadi 84a546a30b [msm_shared/mmc]: data mover for mmc/sd data transfers
- disabled until display patch goes in.

Change-Id: Ia43ff6269d2d193fbaaf0610d1938296a62281d7
2011-05-05 15:56:46 -06:00
Linux Build Service Account 31277d80a1 Merge "msm7x27a: usb: Add usb enumeration support." 2011-05-04 10:23:11 -07:00
Linux Build Service Account 9514579812 Merge "mmc/lk: Adding bounds check when filling mbr name" 2011-05-04 10:23:11 -07:00
Linux Build Service Account 7ff9b84ebf Merge "msm8960: keyboard support" 2011-05-04 00:13:14 -07:00
Kinson Chik kchik@codeaurora.org 4a17b1a7c8 mmc/lk: Adding bounds check when filling mbr name
If partition table has more typed 0x83 partitions than
we expect in read_MBR then there is a possible buffer
overflow. We will try to copy next string out of the
bounds of the string array.

Change-Id: Ibbd0d5b43e5c96e4bd457208b7093da5a7c25047
CRs-Fixed: 285363
2011-05-03 15:21:26 -07:00
Amol Jadi 6db9fe3008 msm8960: keyboard support
Change-Id: I320f948a7b57a2c746ca525106063224e6e02ee2
2011-05-02 18:53:21 -07:00
Shashank Mittal 2ce16456f7 msm8960: Fix memory address and atags.
Change-Id: I847a716428e7e6956cd96472f0e0b57b2f9065e8
2011-05-02 14:39:42 -07:00
Shashank Mittal 59392f3323 msm7x27a: usb: Add usb enumeration support.
For eMMC targets, sending product serial number from CID of
MMC as serial number for USB enumeration to kernel as well as
for fastboot.

For NAND targets, using target name as serial number.

Change-Id: I2704b80f670ae6b415cf220b87534ce94b93848b
2011-05-01 21:08:14 -07:00
Linux Build Service Account 4d0559118c Merge "msm: keypad: Initialize keypad detected to -1" 2011-04-29 16:10:08 -07:00
kchik@codeaurora.org bce18eae81 appsboot/msm_shared: Supporting SSD Fastboot
When SSD is enabled, fastboot will decrypt enc files,
which are encrypted. Using TZ, appsbl will decrypt
image and flash normally if encrypted image detected,
or flash images normally enabled for 8660 emmc.

Change-Id: I85f54a9ad9a17edc42449b225f1f16975fce0a2f
2011-04-28 14:44:54 -07:00
Linux Build Service Account fb9fefa0f8 Merge "msm7x27a: Fix keypad for msm7x27a target." 2011-04-23 02:12:52 -07:00
Shashank Mittal b35f1983b6 msm7x27a: Fix keypad for msm7x27a target.
With new configuration GPIO keypress are active low.

Change-Id: Ia21e1e0cec2d89f8e0b4f6179a7d97454a28dc40
2011-04-21 11:28:32 -07:00
Shashank Mittal 8dcbf70c95 [msm8960]: Increases memory passed to kernel in atags.
Change-Id: I2f88eb96b149d6a041a519dd6f44ee2b16db2c45
2011-04-20 10:20:29 -07:00
Linux Build Service Account e2adacf958 Merge "[msm8660]: Minor change to support power key press in PM8058" 2011-04-19 11:04:43 -07:00
Linux Build Service Account d01737200e Merge "[msm_shared/crypto]: Fix error in hash calculation" 2011-04-14 17:33:18 -07:00
Shashank Mittal 8397844e07 [msm7x27a]: Bumps up ACPU frequency on msm7x27a target.
Change-Id: I796c8400cac81ccebabb65c7274bc3bf04c8572e
2011-04-14 14:40:18 -06:00
Linux Build Service Account 65ea573703 Merge "msm8960: Add 8960 platform specific defines in timer." 2011-04-14 02:28:13 -07:00
Channagoud Kadabi beb17d5292 [NAND]: Use block size from flash info
Current implementation assumes block size of the nand to be 64K always
Added change to get the block size from flash info which helps
supporting NAND with different block sizes with minimal changes and
reduces manual errors

Change-Id: I16bf976b1638ef8a33474e2c347771ed8838a40c
2011-04-13 12:41:41 -06:00
Subbaraman Narayanamurthy 22d53c65e8 [msm_shared/crypto]: Fix error in hash calculation
For data size which is not a multiple of 4 bytes, we calculated the
hash for the left over bytes by wrong byte order. Now we change the
byte order for leftover bytes and calculate the hash properly.

This is a corner case as we always verified images with size of
multiple of 4 bytes.

Change-Id: Ia463894f46440cd6c5d97c2792baec2fc0287ad1
2011-04-12 18:15:50 -07:00
Subbaraman Narayanamurthy aea23b7920 [msm8660]: Minor change to support power key press in PM8058
Change-Id: I148aeb45b45ef47570c59c1e899088dd437e2fb5
CRs-Fixed: 281960
2011-04-12 13:15:26 -07:00
Linux Build Service Account f80b3cd46d Merge "aboot: Add support for "compressed ext4" sparse images" 2011-04-12 00:25:49 -07:00
Ajay Dudani 25478468fa msm: keypad: Initialize keypad detected to -1
Fix detection of row0/col0 gpio keypad.

CRs-Fixed: 281180
Change-Id: I2167947a4676557b6e2836c883bffbe486398d27
2011-04-11 19:41:14 -07:00
Ajay Dudani 5c76113162 aboot: Add support for "compressed ext4" sparse images
Compressed ext4 file system sparse image format is defined by
AOSP and generation of these images is done using ext4_utils
which is also part of Android Open Source Project.

In order to transfer and flash large, empty ext4 filesystems
(userdata) in a reasonable amount of time, we need to store
the image in a sparse format that contains information about
which areas of the filesystem can be left unwritten.

Compressed ext4 file format:

All fields are unsigned little-endian File contains a file header,
followed by a series of chunks File header, chunk header, and chunk
data are all multiples of 4 bytes long

Header:
32 bit magic: 0xed26ff3a
16 bit major version (0x1) - reject images with higher major versions
16 bit minor version (0x0) - allow images with higher minor versions
16 bit file header size in bytes (28 in v1.0)
16 bit chunk header size in bytes (12 in v1.0)
32 bit block size in bytes, must be multiple of 4
32 bit total blocks in output file
32 bit total chunks in input file

Chunk:
16 bit chunk type:
  0xCAC1 raw
  0xCAC2 fill
  0xCAC3 don't care
  0xCAC4 crc
16 bits reserved (write as 0, ignore on read)
32 bit chunk size in blocks in output image
32 bit total size in bytes of chunk input file including chunk header and data
Data:
  for raw, raw data, size in blocks * block size in bytes
  for fill, 4 bytes of fill data

Change-Id: I5ee5c288dae9a8ae364502ae8f32fcab65d2274b
2011-04-11 08:13:58 -07:00
Linux Build Service Account 90ec9ae16c Merge "[msm7x27a]: Enable UART for 7x27a target." 2011-04-11 05:48:28 -07:00
Shashank Mittal 2fad67f009 [msm7x27a]: Enable UART for 7x27a target.
Change-Id: I90a8581f211f32173ec2e4e879debde573bc1bd2
2011-04-08 20:07:21 -07:00
Shashank Mittal 39763075d5 [msm7x27a]: Add support for fastboot and recovery key.
Change-Id: I3f417594889fe6332ab327ac199de7586e123b4f
2011-04-08 19:50:32 -07:00
Shashank Mittal cb25d25504 [msm7x27a]: Add support to read board info from shared memory.
Change-Id: Ie1c5a253f4add513ae934ead41dbd837faaa028d
2011-04-07 19:26:04 -07:00
Amol Jadi 84a64e82e4 msm8960: Add 8960 platform specific defines in timer.
Change-Id: I317e000e7847ca5ab80868a352d4d4aa0efb1a14
2011-04-06 11:41:17 -07:00
Linux Build Service Account 25ad7dfbed Merge "[msm8960]: Fixing code for RUMI." 2011-04-06 08:30:22 -07:00
Shashank Mittal ef3254102c [msm7627a]: Fix code for 7x27a bringup.
-- Add support to make proc comm for USB clocks
-- Add support for new NAND card
-- Fix machine type to MSM7x27A SURF

Change-Id: Ib79a8647d4b97b4b834d992fbbdd1aa1325f0069
2011-04-04 12:06:59 -07:00
Vivek Mehta 5f1c9d4974 fastboot: Increasing the max allowed download size
Creating a function which will return target specific max allowed flash size.

Change-Id: I7ff7d895af1cfea773e628c1a7a6b564043a3517
2011-04-03 13:19:07 -07:00
Shashank Mittal da89a689d0 [msm8960]: Fixing code for RUMI.
-- Fix uart for RUMI target
-- Add support for run time detection of machine type
-- Fix mmc for RUMI target

Change-Id: Ie439cf79b95c2aff2e9aed8f905f9d30caacaa34
2011-04-01 16:02:54 -07:00
Linux Build Service Account 7bc2458954 Merge "msm7627: Add secure boot support to appsbl" 2011-04-01 10:35:08 -07:00
Channagoud Kadabi ef9b47ddcc msm7627a: Add secure boot support to appsbl
mkheader contains additional functionality to combine header+raw
appsbl(unsecure appsbl) or header+raw+signature+certificate
(secure appsbl).

Change-Id: Ifabbb02e4f8bc0d81e56c017436f187fc2837d40
2011-04-01 13:22:09 +05:30
Channagoud Kadabi c3fad8852d msm7627: Add secure boot support to appsbl
mkheader contains additional functionality to combine header+raw
appsbl(unsecure appsbl) or header+raw+signature+certificates
(secure appsbl).

Change-Id: I6aaeb2150c9e55122beebce58599f6cf78f25e7d
2011-03-31 18:27:09 +05:30
Subbaraman Narayanamurthy bd2424e943 [lk]: Fix wrong debug message for power on status
Change-Id: I96d82d7a8567e455913ac1094c391d76fe27b513
2011-03-29 15:29:21 -07:00
Ajay Dudani 7dd11b14ee msm: Recognize 'tombstones' partition
Change-Id: I05726bc5c4ae09bcb244a7741ed8bf40f274714e
2011-03-27 14:34:53 -07:00
Linux Build Service Account 89efbbe281 Merge "msm7627: Fix misc partition size as current size fails to mount in kernel" 2011-03-27 13:13:23 -07:00
Wentao Xu 97df7fd2f4 msm7630: Add support for 7630 fluid LCD panel
Change-Id: Ia6e8ecfe2c9e299717ad7db4e58d3fd5d7e5710b
2011-03-24 17:31:31 -06:00
Ajay Dudani 81990747fd msm7627: Fix misc partition size as current size fails to mount in kernel
CRs-Fixed: 280373
Change-Id: I4a9223b857868e6f35ee78f8501fee32c9033ece
2011-03-23 17:00:37 -07:00
Srilakshmi Punuru 205ac51288 msm7627_surf: Increase the system partition size by 5MB
Change-Id: I954a074ad2669c260338c0a88c79a06a5535779b
2011-03-17 11:59:39 -06:00
Shashank Mittal 04059b73c8 [NAND]: Fix length for VARIABLE LENGTH partitions.
CRs-Fixed: 279026

Change-Id: I1adf3d9170df9dec2b801d5b7deb8a74263e1a8a
2011-03-15 20:44:29 -07:00
Linux Build Service Account 9301769092 Merge "[msm8660]: Add fastboot key detection for QT8660" 2011-03-12 21:38:36 -08:00
Subbaraman Narayanamurthy 8f0b045a87 [msm8660]: Add fastboot key detection for QT8660
Due to a hardware design bug, keypad controller in PM8058 could not be
used for key detection. Hence detecting it by configuring PM8058 GPIOs
as normal function and accessing it over SSBI

Change-Id: I92db69fe504598a6d1dfc0736642b1cb7a02be4c
2011-03-11 19:04:22 -08:00
Chandan Uddaraju c1df565203 msm: mipi_dsi: Fix kernel panic issue for MIPI DSI builds.
Interrupts are generated as soon as the DSI controller is
initialized in the kernel driver. Reset the interrupt
mask register for DSI controller before entering kernel.

CRs-Fixed: 275202
Change-Id: I2ccd98f8eb955254f74047f88b4f323c44b7cb2b
2011-03-11 12:25:40 -08:00
Chandan Uddaraju 3cbbd302ab msm: mipi_dsi: Enable secure IO for MIPI DSI display driver.
MIPI DSI display driver needs to enable clocks that
are part of MMSS clock control. Enable secure IO to
enable/disable dsi clocks.

Change-Id: I7e09333b3229a1631c75a5a28b0a3b2c6761a0fa
2011-03-11 11:48:11 -08:00
Subbaraman Narayanamurthy 7c674100fa [msm_shared/mmc]: Set high speed for sD card properly
Setting high speed mode for sD card properly.Without this, setting bus
width to 4bit was failing in class 2 sD card.

Decode CID fields for sD card properly as we use PSN for serial number
in fastboot and adb enumeration.

Change-Id: I63ca4e7bc77c274f9d7d6074a327ae0e483ba5f3
2011-03-10 22:33:07 -07:00
Ajay Dudani 91b0427458 aboot: Update to choose between 4.4.0 or 4.4.3 toolchain based on environment
Change-Id: I0b56bd8336dbe4a470c202f5587517f2275d0b49
2011-03-09 16:02:16 -08:00
Linux Build Service Account 6dc5e46ee0 Merge "msm7627a: Update cache size to be 4M to yaffs block size limitation" 2011-03-07 12:36:59 -08:00
Shashank Mittal 561450e241 msm7627a: Update cache size to be 4M to yaffs block size limitation
The number of reserved blocks is currently hard-coded to 5 for yaffs
kernel driver; increasing cache size to live with this limitation.

Change-Id: I658b5b030490a56eebcdf8b1fce8bb2195e99919
2011-03-04 19:53:32 -08:00
Amol Jadi cd43ea06e8 msm8960: adds dedicated platform dir for 8960
Plus other minor cleanup.
Plus RUMI3 support.

Change-Id: I558f69df66d121b3cd982ed4e09622559af19022
2011-03-03 00:29:18 -07:00
Linux Build Service Account 56eec08ba5 Merge "[msm8660]: Enable crypto driver in 8660" 2011-03-01 18:59:14 -08:00
Linux Build Service Account 9634cc195b Merge "[msm7x27a]: Initial commit to support 7x27a target." 2011-03-01 13:32:25 -08:00
Subbaraman Narayanamurthy 05872db60d [msm8660]: Enable crypto driver in 8660
Change-Id: I9d7cf20c57448cce9356109d317198ea7c1a1dff
2011-02-28 11:34:58 -08:00
Ajay Dudani 4e3ae0ba8f msm8660: Reducing 1M of total usable memory passed to kernel
non Linux components (TZ) need small chunks of additional memory.
Taking this out from kernel for these other components.
2011-02-28 08:56:54 -08:00
Subbaraman Narayanamurthy 346bdcbed7 [msm8660]: Switch watchdog to use secure io call
fastboot reboot uses watchdog reset which needs to be accessed via
secure io call.

Change-Id: Iba9098821007e87257ce8736c73b56394059beb4
CRs-Fixed: 276603
2011-02-26 10:40:53 -07:00
Subbaraman Narayanamurthy f17b4ae3be [aboot]: Send serial number for USB enumeration
For eMMC targets, sending product serial number from CID of MMC as
serial number for USB enumeration to kernel as well as for fastboot.
For NAND targets, using target name as serial number.

Change-Id: I9cbf865ba8a7747ad89c7d12461b91d07a8d5403
CRs-Fixed: 276165
2011-02-25 17:47:55 -07:00
Ajay Dudani 295f38b274 msm8660: User platform subtype to detect machine id
When board info v6 is available, use platform subtype to correctly
detect machine id.  board info v5 fused chip fails to detect machine
id correctly in some hardware combinations but is used as a backup
if non-hlos does not support board info v6 or higher.
2011-02-25 15:28:07 -08:00
Linux Build Service Account 4f7dcb93d5 Merge "[msm8660]: Add support to read status of specific GPIO pins for PM8058" 2011-02-25 10:49:30 -08:00
Linux Build Service Account 25bb646c65 Merge "msm8660: Update reboot reason code shared address with kernel" 2011-02-25 02:43:54 -08:00
Linux Build Service Account 10136031c0 Merge "msm8660: Switch mdp and pixel clock to use secure io calls" 2011-02-19 15:05:27 -08:00
Ajay Dudani 9496f9a230 msm8660: Update reboot reason code shared address with kernel
Change-Id: I90e39c8ef030557e4344fb6baeaa28d319a32b5e
2011-02-18 11:03:29 -07:00
Linux Build Service Account 9d4495a33c Merge "[msm8660]: Add support to read ver.5 and ver.6 of board info from smem" 2011-02-18 06:05:50 -08:00
Subbaraman Narayanamurthy 78aa8fefbe [msm8660]: Add support to read status of specific GPIO pins for PM8058
Change-Id: I88ef878186ac741eb15323d8f7af1f0cb10b028c
CRs-Fixed: 275455
2011-02-17 18:21:31 -08:00
Subbaraman Narayanamurthy 83019a4502 [msm8660]: Set LCD panel voltage to 3.3V
Setting LDO L2 voltage to 3.3V for LCD panel.

Change-Id: I1768f21c2f15364624b98f4c99f7b7e14682546a
2011-02-15 20:08:02 -08:00
Shashank Mittal 246f8d0fc1 [msm7x27a]: Initial commit to support 7x27a target.
Change-Id: Ibc8e40c40fe1ea8071f51d9f1d65f3b766bf2f9c
2011-02-14 23:25:14 -08:00
Shashank Mittal 2249a071a0 [msm8660]: Add support to read ver.5 and ver.6 of board info from smem
Change-Id: If5fdc1214eadc00cfa854cec371e898ecf494d35
2011-02-14 23:20:09 -08:00
Ajay Dudani edc015a023 msm8660: panel: Set voltage to 3.3V during init
Change-Id: I8d17f251b8b90afed4572dff5dc2b708d88a57ab
CRs-Fixed: 274847
2011-02-10 13:06:47 -08:00
Ajay Dudani 6cff85ed7f msm8660: Add support to detect platform subtype
board_info v5 does not always detect fused chip correctly.
As a result board_info v6 has new entries to detect platform
subtype and thats what we want to use eventually.

Adding support for board_info v6 structure, while maintining
support for board_info v5 for the time being.

Change-Id: I46447edd561f1d9e306741f0113c3e2ef17ae3e1
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-02-08 14:20:53 -08:00
Srilakshmi Punuru cfb5a46ddc msm7627: Add support to detect machine type dynamically.
Change-Id: I7af8b670b580473968cd69abd05c1a7c94aacc96
2011-02-08 11:57:00 -08:00
Linux Build Service Account 583f27068c Merge "msm8660: scm-io: Support secure io operations" 2011-02-08 03:55:20 -08:00
Linux Build Service Account e2b7d72b29 Merge "[msm8660]: Switch to HS USB PHY for QT8660" 2011-02-08 00:10:07 -08:00
Ajay Dudani a5362efe3b msm7627: Update cache size to be 4M to yaffs block size limitation
The number of reserved blocks is currently hard-coded to 5 for yaffs
kernel driver; increasing cache size to live with this limitation.

Change-Id: Ia54d128cdf179ea6c0c2001688fc10801bfe6086
2011-02-07 00:41:56 -07:00
Subbaraman Narayanamurthy b0111a1c37 [msm8660]: Switch to HS USB PHY for QT8660
By default micro usb connector is connected to FS USB PHY. Switching
it to HS USB PHY via GPIO.

Change-Id: I1ced8efe6fc2eedebdccd486ae1ea875783872b3
2011-02-04 13:00:08 -08:00
Subbaraman Narayanamurthy 31c174ece7 [msm7627]: Support MMC slot change in LK
SDC3 slot is used in 7627 rev2.0 hardware now.Hence detecting MMC on
that slot first.

Change-Id: I9d243c42474df8bce342601b28c74c2daf41f113
2011-02-04 12:35:09 -08:00
Ajay Dudani 012f8f19e6 msm8660: Switch mdp and pixel clock to use secure io calls
Change-Id: Ibbf19c7f8caa41715df841dd3706a1dcd415b5c8
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-02-01 16:36:26 -08:00
Ajay Dudani 8534b1aab1 msm8660: scm-io: Support secure io operations
Some registers accesses need to be done securely. Implement a thin
API similar to readl/writel which requests the secure side to
read or write a register securely.

Change-Id: If41f7321877ceead7ab38f36faeee1114bd82f4d
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-02-01 16:36:11 -08:00
Linux Build Service Account 28e54d265b Merge "[msm_shared/crypto]: Add SHA1 support to crypto driver" 2011-02-01 11:00:50 -08:00
Linux Build Service Account e78a375b9b Merge "msm: mipi: Disable all 4 interrupt sources as part of mipi shutdown" 2011-01-29 14:31:19 -08:00
Subbaraman Narayanamurthy 8fcccbd3d8 [msm_shared/crypto]: Add SHA1 support to crypto driver
Modified crypto driver to calculate both SHA1 and SHA256 digest
based on the authentication algorithm type passed to it.

Change-Id: I34805ee9a80c49dd073e0dc0651bb4bf89a17e14
2011-01-28 13:42:28 -08:00
Ajay Dudani 8fb360991f msm: mipi: Disable all 4 interrupt sources as part of mipi shutdown
Change-Id: Ic0fd36cbf7e3b9828027a9e792f2d66f4eb65d37
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-01-28 08:14:24 -08:00
Subbaraman Narayanamurthy 958fa24949 [aboot]: Check ramdisk size before reading it from MMC
Change-Id: I246a413acafc134b896c597f6a411752ac8f1525
2011-01-27 17:51:44 -08:00
Linux Build Service Account 3a16b67daf Merge "[msm8960]: Initial support for MSM8960." 2011-01-25 23:48:07 -08:00
Amol Jadi d5bf823a73 [msm_shared/i2c_qup]: Updated debug prints levels
Debug prints should not be printed at runtime.
Changed level from CRITICAL to INFO.

Change-Id: Id89b749078bba2f3a4a0e6b20ff0532a42941bb7
2011-01-25 21:36:58 -08:00
Amol Jadi ca4f4c92ab [msm8960]: Initial support for MSM8960.
What is working in this patch:
- Fastboot flash boot.img on to eMMC
- Fastboot boot
- Boot boot.img from eMMC

Not in this patch:
- Clock settings are not done in LK. Expects
  startup scripts to setup the required
  clocks.

Change-Id: I230bb92c6b214976a84a79a7f770f190e822f647
2011-01-25 21:56:36 -07:00
Linux Build Service Account f29397102b Merge "[msm_shared/mmc]: MMC driver update" 2011-01-25 20:44:01 -08:00
Linux Build Service Account 3101410243 Merge "[msm8655]: Add feature flag to build Trustzone with LK" 2011-01-25 19:49:46 -08:00
Subbaraman Narayanamurthy 9b7276cd3f [msm_shared/crypto]: Add crypto engine driver for secure boot
Adding crypto engine driver for hashing boot image for secure boot.
Currently it supports SHA256 only.

Change-Id: I2a1bbb9eb4cb894aabee3520e7439cd5a7e46a3b
2011-01-25 17:36:07 -08:00
Linux Build Service Account 1fe072a058 Merge "[msm8655_surf]: Add msm8655 target to LK" 2011-01-25 14:27:09 -08:00
Subbaraman Narayanamurthy 8bcd5fdbfc [msm8655]: Add feature flag to build Trustzone with LK
Add ENABLE_TRUSTZONE compile time flag to allow Trustzone
initializations with LK. The linker scripts move LK up in
memory, making room for TZ sysini to be placed at reset
vector and take control of Scorpion from power up itself.

This is a partial solution to enable TZ as part of LK.The
TZ/code/image itself is currently not part of LK tree and
is managed separately.As a result, this feature will be
turned off by default.

Change-Id: I1b4e4b380c415428fe22f34563a97440082befee
2011-01-25 12:10:55 -08:00
Shashank Mittal cbd271d4f7 [msm_shared/mipi]: Add MIPI DSI read function.
Add support for DSI read function to read manufacture id of mipi device.

CRs-Fixed: 268845

Change-Id: I719f17b655c36dd3884e5a85cb1487d300f4de85
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
2011-01-25 10:35:07 -08:00
Ajay Dudani 59606436bc msm8660: Check for poweron reason from smem and pass it over to kernel
Change-Id: I70969094a5ab59d94df92ba490ba0d67ead23d86
2011-01-24 18:23:38 -08:00
Amol Jadi 3672fef3f3 [msm_shared/mmc]: MMC driver update
- Fixed MMC card capacity calculation.
 - Use fixed number of blocks when doing mulit-block read on MMC card
   Needed for virtio platform, which does not support
   open-ended multi-block reads.
 - Also had to update the logic for sending the switch cmd to MMC,
   since it failed to work after the above changes.

Change-Id: Ibff14c04fcf531d1e7c69da672cb882d70ceb845
2011-01-24 11:23:20 -08:00
Linux Build Service Account e7e29fd14a Merge "[msm8660_surf]: Add support to use volume up key to go into recovery mode." 2011-01-24 09:22:22 -08:00
Ajay Dudani 35e7aae64c gpio_keypad: Set kypd_enable flag when configuring keypad ctrl reg
Change-Id: I308ae04d5572f54cb46b46dda235849eb65656c2
2011-01-20 22:24:16 -08:00
Linux Build Service Account df44480cdc Merge "[msm7630]: Support local clock control for MDDI display" 2011-01-20 16:26:15 -08:00
Subbaraman Narayanamurthy 641dadcf1a [msm7630]: Support local clock control for MDDI display
Change-Id: Ic8ed24a016efb8de8a83bbe8e34f8491dc6b4e1e
CRs-Fixed: 271867
2011-01-20 14:05:56 -08:00
Linux Build Service Account c88cc16c2d Merge changes I6c19340b,I6c3cbf9b
* changes:
  gpio_keypad: reset the column value for each row
  gpio_keypad: program the correct row/col values into the pmic
2011-01-20 03:13:50 -08:00
Subbaraman Narayanamurthy d962c79eba [msm7630]: Switch to local clock control for MDP and LCDC clocks
Change-Id: If246f14d8446cfde223dfd0aeae0a287729a2045
2011-01-19 21:01:01 -08:00
Ajay Dudani 1c798cf817 msm7630: Add support for 1.4 GHz variant
Change-Id: Ibdce12767b96c4e4f6ab45d1e1f866a7ad148be0
2011-01-19 17:02:49 -08:00
Ajay Dudani d04110c07d msm: Add support to detect and pass androidboot.baseband
Change-Id: I62ab5f012fe1130b7df1d05a62a3819b5e8c1864
2011-01-18 14:03:56 -08:00
Subbaraman Narayanamurthy df66af1678 [msm8655_surf]: Add msm8655 target to LK
Change-Id: I9ccc8df8645a67a5d3dde8b0c5366d8012225440
2011-01-17 15:19:38 -08:00
Ajay Dudani 8b3262af4f msm8660: Add support for QT hardware variant
Change-Id: I0533e5ea65921bcdc9a9810a6fa8a132de30eec5
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-01-17 13:58:57 -08:00
Dima Zavin 8090690c3c gpio_keypad: reset the column value for each row
Change-Id: I6c19340be83cf87a22c0eef31007a02dac59a867
Signed-off-by: Dima Zavin <dima@android.com>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-01-14 16:43:33 -08:00
Dima Zavin aacfed2c42 gpio_keypad: program the correct row/col values into the pmic
Change-Id: I6c3cbf9b238399cdacee76001a0342eb0a332ee6
Signed-off-by: Dima Zavin <dima@android.com>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-01-14 16:43:27 -08:00
Dima Zavin b6da17dc5e msm7630_surf: don't include IMEM region as a memory bank
Change-Id: I333baa9437f4cfa428567b4e5c692b1bee2025f1
Signed-off-by: Dima Zavin <dima@android.com>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
2011-01-12 14:44:41 -08:00
Linux Build Service Account 73b2fb5d70 Merge "[msm_shared/mmc]: Add support to recognize 'mdm' and 'cache' partitions." 2011-01-08 02:59:52 -08:00
Shashank Mittal 5ff3dd2bfc [msm8660_surf]: Add support to use volume up key to go into recovery mode.
Change-Id: Ib77de34670067c1f8e85eb444d2b835593a4acfd
2011-01-07 18:54:16 -08:00
Shashank Mittal 5a5a543db9 [msm_shared/mmc]: Add support to recognize 'mdm' and 'cache' partitions.
Change-Id: I7f13f4c6d199fdbca514b696de050622a2e9e2a1
2011-01-07 18:51:49 -08:00
Linux Build Service Account bc1d43ce61 Merge "msm7630: Volume +/- to enter recovery/fastboot mode for Fluid" 2011-01-07 10:07:58 -08:00
Ajay Dudani 55e05d5d6e [msm8660] Update restart reason address from ebi to imem
Move restart reason to be saved in imem instead of ebi to ensure
this stays valid across reboots.

Change-Id: Ic3db7d585c67d76d65be80f9546fc9679bd14c22
2011-01-05 18:29:34 -08:00
Wentao Xu 153902c0b2 msm7630: Volume +/- to enter recovery/fastboot mode for Fluid
Change-Id: Ib30c711749205d03124ba256b14697881fd24cb1
CRs-fixed: 268251
2011-01-04 18:18:39 -05:00
Shashank Mittal 86b2148080 [target]: Fixing machine Ids for all targets.
Change-Id: Ie9bd2551d65df02b1a617e7de9cb580218ed9b8a
2010-12-29 20:15:50 -08:00
Linux Build Service Account bc208061da Merge "[msm8660] Fix DGT timer divider" 2010-12-23 14:07:41 -08:00
Ajay Dudani 0cddb7aa27 [msm8660] Fix DGT timer divider
Change-Id: I6afafe9d9f4b08491e4d336626ab25b140d22e09
2010-12-22 18:14:02 -08:00
Linux Build Service Account 815a3d1d62 Merge "[msm_shared/uart]: Fix UART for msm7x30 targets." 2010-12-22 17:49:49 -08:00
Linux Build Service Account 78045236f6 Merge "[msm7k]: Fix ACPU clock initialization" 2010-12-22 16:39:37 -08:00
Linux Build Service Account 7a11d611f1 Merge "[msm_shared/mmc]: Check MMC state before setting high speed" 2010-12-22 14:55:08 -08:00
Shashank Mittal 1ddc04cde8 [msm_shared/uart]: Fix UART for msm7x30 targets.
Change-Id: Ia73565b51c4014077d382f1baef78b25fb7fc57d
2010-12-22 14:41:47 -08:00
David Ng 9055606cb0 lk: Force GCC 4.4.0 for Android LK build and update eMMC check flags
Change-Id: I82fedb4c4ff4e7471af2c78bf0b63fc069d5b438
2010-12-20 18:38:31 -08:00
Linux Build Service Account 89c7b5b62b Merge "[msm_shared/mmc]: Add support for low capacity MMC and SD cards." 2010-12-17 23:09:36 -08:00
Subbaraman Narayanamurthy 8282bdc9c8 [msm7k]: Fix ACPU clock initialization
- Using right clock source select while doing ACPU clock
initialization.

Change-Id: I0066bdf1b720617116c787e32c920f7d3d5e54ec
2010-12-17 18:10:11 -08:00
Subbaraman Narayanamurthy 29308e0e99 [msm_shared/mmc]: Check MMC state before setting high speed
CR-Fixed: 268075
Change-Id: I6a760be3d71998fc0290536ab2095abd2e57a646
2010-12-17 14:04:10 -08:00
Ajay Dudani 81f9a78f2a [lk] Add timestamps to dprintf logs for easier performance analysis
Change-Id: I0c4add52d9c6fc2a5e5e50bfee05156371a6632e
2010-12-16 20:27:44 -08:00
Shashank Mittal 999d4ee711 [msm_shared/mmc]: Add support for low capacity MMC and SD cards.
CR-Fixed: 263743

Change-Id: I4c707c892ee4a1e30db5769e5de19c6692983cc5
2010-12-16 12:35:48 -08:00
Kinson Chik kchik@codeaurora.org 1cb7b4d3f2 boot/lk: msm7630/8660_surf adding max cert chain size check
Check maximum cert chain size input from user to be less than
the total number of certificates provided by user which gets
concatenated to become the certificate chain.

Change-Id: Iea731dee8267851c8492fe90c3ce0cdde6604f3c
2010-12-15 15:00:59 -08:00
Linux Build Service Account 92a6e7fb92 Merge " [target/msm7630] Get power on reason and pass to kernel for fluid" 2010-12-12 15:00:34 -08:00
Ajay Dudani 87047ca0e6 [msm7630_1x] Increase cache and misc partition to support image upgrades
Change-Id: I1f63ae0c878fd4ca82a4bebbbe5cc54289fbc979
2010-12-10 18:03:13 -08:00
Ajay Dudani cacccef7b7 [msm7630_1x] Remove redefinition of platform id
Change-Id: Ie62053481eb976174590c64096ef3fb36550e60c
2010-12-10 17:59:25 -08:00
Wentao Xu 530c2d8028 [target/msm7630] Get power on reason and pass to kernel for fluid
Added similar method from msm7627_* to target msm7630. Added a check
 to work only for fluid device

 CRs-fixed: 251522

Change-Id: Id3cbd887e04fb741931d6d19cc5a3ab541f6da21
2010-12-10 17:23:34 -07:00
Linux Build Service Account 19d100ff0b Merge "[platform/msm_shared]: Add support for new Micron NAND flash memory." 2010-12-09 21:48:35 -08:00
Linux Build Service Account d21942b947 Merge "[msm7630_1x/DMM] : Reserve EBI-1 memory as unstable." 2010-12-08 19:21:52 -08:00
Shashank Mittal ab958e5012 [platform/msm_shared]: Add support for new Micron NAND flash memory.
CR-Fixed: 267016

Change-Id: Ie4892fc42d57e83c4d2b52f5d70c0d4d0f07759c
2010-12-08 10:01:04 -08:00
Subbaraman Narayanamurthy e9f077b639 [msm_shared/mmc]: Add write protection for eMMC partitions.
Enable write protection for eMMC partitions based on the write group
protection availability in the card.

Write group protection availablity is checked by reading CSD.
If it is available, then write protect group size is calculated from
EXT_CSD or CSD based on ERASE_GROUP_DEF.

SET_WRITE_PROT is sent for the number of write protect groups to be
protected. For e.g. if 10MB is to be protected from a starting sector
and if write protect group size is 4MB, then 3 groups of 4MB i.e. 12MB
from the starting sector will be write protected.

For clearing user power-on write protect, CLEAR_WRITE_PROT is sent and
it is similar to SET_WRITE_PROT.Note that the sector to be write and
the size should be specified in sectors.

Change-Id: Ic1e6809d17c2733666140ae793b38bf8d0815664
2010-12-07 13:26:08 -07:00
Chandan Uddaraju fe93e82532 [msm8660]: Enable MIPI DSI Novatek panel display
Add code to support two lane command mode for MIPI DSI
novatek blue panel.

Change-Id: I84cb14bba243f2ab6b30d4a60128fc60a61a56df
2010-12-03 11:53:14 -08:00
Karthik Parsha 5471fd5dbe [msm7630_1x/DMM] : Reserve EBI-1 memory as unstable.
Change-Id: I57d0fb389941693801921cecd50fa792d838701a
2010-12-01 13:08:01 -08:00
Ajay Dudani 16ea8fb74a msm8660: Add support to detect 8660 charm target
Read socinfo to detect if target is a charm target. Use this
information along with hardware platform information to use the
right machine id for Linux kernel.

Change-Id: Ibf536f8f0a6e44e99336d6d054f9fda588a58608
2010-11-24 11:32:44 -08:00
Linux Build Service Account 69d1c3b198 Merge "msm: msm7630/8660(emmc): Add secure boot support to appsbl" 2010-11-23 13:19:36 -08:00
Kinson Chik c874a2be7e msm: msm7630/8660(emmc): Add secure boot support to appsbl
mkheader contains additional functionality to combine header+raw
appsbl(unsecure appsbl) or header+raw+signature+certificates
(secure appsbl).

Change-Id: I0acda1c57a64f653a51669a711ccb0301392e802
2010-11-18 15:28:32 -08:00
Shashank Mittal 0dab8f5996 [msm7x30] Add code to bump up ACPU clock.
Sets msmc2 voltage to 1.2V and bumps up ACPU frequecy to 806MHz/1GHz on
7x30/8x55 target.

Change-Id: Ic70576bc1bc31799219966ab97270e6bfa7073ae
2010-11-18 10:55:48 -08:00
Linux Build Service Account 851313163c Merge "msm: msm7630(nand): Add secure boot support to appsbl" 2010-11-16 13:01:34 -08:00
Kinson Chik 6a7be43f36 msm: msm7630(nand): Add secure boot support to appsbl
mkheader contains additional functionality to combine header+raw
appsbl(unsecure appsbl) or header+raw+signature+certificates
(secure appsbl).

Change-Id: I1fd10ecbc69b6ab2ef253621b23371d53a398e68
2010-11-16 09:56:56 -08:00
Ajay Dudani 5b1d04552c [msm] Switch to using MDP direct mode for MDP4 targets
Change-Id: I6f0d57ad7f88fd2e81dcdbba97e45ca17a06083d
2010-11-11 19:07:30 -08:00
Linux Build Service Account fac99851e6 Merge "Disable stack protection code emission" 2010-11-09 15:08:04 -08:00
Christopher Johnson 36cd703c46 Disable stack protection code emission
When building natively within a QEMU environment, stack protection
code is emitted by default. However, because the bootloader's libc
implementation doesn't support this, it needs to be disabled.

Change-Id: I2f612ecdd773b8c4455813b3e5acba5ca713ebe6
2010-11-09 14:46:30 -07:00
Ashish Singhal 1463888d32 bootloader/lk: Add new msm8655_surf target
Clone 7630 as 8655

Change-Id: I2103ddea39aa3dbdcfd8bd188884b46c17ca38f6
2010-11-09 14:02:44 -07:00
Chandan Uddaraju 78ae675783 [msm8660]: Enable MIPI display support for Toshiba MIPI panel.
Add code to configure MDP DSI module to support MIPI DSI interface. Add support
to configure Toshiba MIPI panel.
Enable DSI Core clock, DSI BYTE clock, DSI CORE_P clock

Add a new character array representing the QuIC Logo in RGB888 format.

Change-Id: Ic638f5b42998896e8f7750b56457ff091eb91b81
CRs-fixed: 259879
2010-11-04 16:17:24 -06:00
Linux Build Service Account da3ea15eb8 Merge "[msm8x60] Add support for uart in 8660 bootloader." 2010-11-04 03:54:35 -07:00
Shashank Mittal 9d68d1d4a7 [msm7x30]: Revert ACPU clock frequency to 768MHz
CR-Fixed: 262032

Change-Id: Ie89b010131044cfc82682b8cac148058d0a9b81b
2010-11-02 19:36:43 -07:00
Linux Build Service Account 450d47cb75 Merge "[msm_shared/mmc]: Add support to read/write recovery partition on mmc device." 2010-11-02 10:53:03 -07:00
Shashank Mittal 85b91f6e0d [msm_shared/mmc]: Add support to read/write recovery partition on mmc device.
Change-Id: Ife4b60b69b2042564051e992059fddc8136d1c3c
2010-11-01 14:40:58 -07:00
Bikas Gurung d1aa5903b5 [msm8x60] Add support for uart in 8660 bootloader.
Initialize and configure UART_DM in legacy mode (without
Data Mover) to support UARt in bootloader.

Features currently supported/unsupported:
- Legacy mode - no Data Mover
- Support RX/TX path
- No TX/RX Flow control
- Polling mechanism rather than Interrupt based
- Watchdog timeout not handled during long wait

Host Configuration:
Speed: 115200
Data bits: 8
Stop bits: 1
Parity: None
Flow control: None

CRs-fixed: 243843

Change-Id: I0296f77a40bf3e2f0e4040774a9820e836ca588e
2010-11-01 13:18:03 -07:00
Linux Build Service Account 35342b2e7e Merge "msm7630_1x: Fix partition table to not overlap system and cache" 2010-11-01 11:48:47 -07:00
Ajay Dudani eb5024207d msm7630_1x: Fix partition table to not overlap system and cache
Change-Id: I0cc655f731ebe2b160306cf48d797d9ad6bed0c3
2010-10-29 22:54:17 -07:00
Subbaraman Narayanamurthy 7d34774e2b [msm_shared/mmc]: Check MMC/SD card status before setting bus width
Check MMC/SD card status before setting bus width which otherwise cause
command timeout and apps boot fails in MMC/SD initialization.

Change-Id: I5067f9d110bb9fbf8887add68f7c9335e14a0978
2010-10-29 21:24:08 -07:00
Linux Build Service Account 354af5c6f3 Merge "[msm7x30]: Turn off MDP before jumping to HLOS." 2010-10-29 13:56:18 -07:00
Shashank Mittal 58317a7db4 [msm7x30]: Turn off MDP before jumping to HLOS.
This change turns off mdp just before jumping to HLOS in LCDC mode.

Change-Id: Ic2e0029b47aa6ef7ce62bba65edd9954a7e49174
2010-10-29 11:30:38 -06:00
Ajay Dudani 774212980a [msm8660] Add support for reboot reason code
Linux kernel writes to shared location in APPSBL EBI; apps bootloader
reads this location the reboot reason, scrubs it and acts accordingly.

This location may move to IMEM area in future once room is made for
HLOS in IMEM.

Change-Id: I39b45cad6bbd25fdbc513ef74eb2608fc8b37cf8
2010-10-29 04:04:39 -06:00
Linux Build Service Account caa2a03bdd Merge "[msm7630_1x]: Add msm7630_1x target to support 1.x modem builds" 2010-10-28 19:01:40 -07:00
Linux Build Service Account 80fe2196b4 Merge "[msm7x30]: Add support for Rev2.1 chip id" 2010-10-28 17:21:43 -07:00
Linux Build Service Account 2647071158 Merge "[msm8x60]: Remove support for bringing secondary core out of reset" 2010-10-27 23:58:07 -07:00
Subbaraman Narayanamurthy 2a8fd54c3b [msm7630_1x]: Add msm7630_1x target to support 1.x modem builds
Change-Id: Icbfdaaf650640c2b607b6aa2f26a968aa8b410ba
2010-10-27 16:29:50 -07:00
Subbaraman Narayanamurthy 492c8c02ce [msm7x30]: Add support for Rev2.1 chip id
Change-Id: I65934b9095d3ca84f7a0503c1c0c6b9b1c39f4b6
2010-10-27 11:41:49 -07:00
Shashank Mittal 8243bc44ad [msm8x60]: Remove support for bringing secondary core out of reset
HLOS would be responsible for bringing secondary core out of reset.

Change-Id: Ibf595120e45a3a911eba452aba0ede8e1b9137ea
2010-10-26 11:51:17 -07:00
Ajay Dudani b275c44a3e [msm8660] Drop MM AXI bus setup during MDP initialization
Drop programming PLL1 (MM_PLL0) as this is now done earlier
in boot chain.

Change-Id: I3a8df7d32f197b971ce50ba367148b470f6bc789
2010-10-25 21:00:46 -07:00
Linux Build Service Account d2b4499038 Merge "[msm_shared/mmc]: Add ST1,ST2,EFS2 partitions to partition table." 2010-10-22 10:45:20 -07:00
Subbaraman Narayanamurthy 4dfe44a2d6 [msm_shared/mmc]: Add ST1,ST2,EFS2 partitions to partition table.
Add ST1,ST2, EFS2 partitions to partition table of apps boot if it is
present in MBR/EBR. Erasing NV items will be easy with this.

Change-Id: I35005420d205d8fe70a364f080bbc14aaf1b7f27
2010-10-21 17:58:09 -07:00
Linux Build Service Account b0d44785d7 Merge "[msm7630] Bug fix to not overwrite r3 value when checking for halcyon v1" 2010-10-20 13:56:59 -07:00
Ajay Dudani 9b794580a0 [msm7630] Bug fix to not overwrite r3 value when checking for halcyon v1
We check for halcyon v1 we use r3; same register is used later to pass
on cache settings.  Use r4 instead when checking for processor version
so we dont overwrite the cache setting value in r3.

Change-Id: I22430f0bb766b49ee0431f0a6b7fe413fc23ca56
2010-10-19 19:56:17 -07:00
Shashank Mittal 97491492aa [msm8660] Add support for 8660 csfb variant
Change-Id: I29dbd007e3374f65a3893cd6a1ac60f81274d5d5
2010-10-19 16:56:14 -07:00
Subbaraman Narayanamurthy 4cc2973db7 [msm7x30]: Enable ADM clock in apps bootloader.
Early boot chain disables ADM clock after boot hence enabling it in
apps bootloader to read/write NAND.

Change-Id: I6b26344baddebcaeafbedcd66b8fc1f7a0779a05
2010-10-18 15:57:58 -07:00
Linux Build Service Account e36682fe8b Merge "bootloader/lk: Add new msm7630_1x target" 2010-10-18 02:49:18 -07:00
Linux Build Service Account ad9dbc64a6 Merge "lk: Increase system partition by 5MB for 7x30, 8x50(a) NAND flash targets" 2010-10-15 16:48:04 -07:00
David Ng 3755bb8122 lk: Increase system partition by 5MB for 7x30, 8x50(a) NAND flash targets
Change-Id: I2e8d4243687931185440a218e61278c4cce24e56
2010-10-14 16:31:50 -06:00
Ajay Dudani b076f729f3 [msm7630] Drop unified boot header
Drop unified boot header as we are not expecting osbl to load boot.img
Save osbl from checking the header and attempting to load boot.img as
it also helps boot time performance.

Change-Id: I1c4138dcd5bc2b5b669aa69c82dcbf9290ec4d5b
2010-10-14 11:50:40 -07:00
Linux Build Service Account 36fcf87bff Merge "[msm_shared/mmc]: Enable sD card detection and eMMC driver in apps boot" 2010-10-14 07:38:27 -07:00
Deepika Sai Amuri 454c0a5da5 bootloader/lk: Add new msm7630_1x target 2010-10-14 14:33:58 +05:30
Chandan Uddaraju c009e4d6ea [platform/msm7630]: Enable MDDI display in android bootloader.
--Initialize MDDI host and client
  to enable display. Enable PMDH and PMDH_P clock using proc comm.
--Add code to configure voltage regulators using SSBI writes.

By default, Display in bootloader is disabled on this target.

This code doesn't have support for Local clock control. To further
optimize the code, PMDH and PMDH_P clock should be enabled in the
modem bootloader code instead of enabling them in application
bootloader.

Change-Id: Ie10f8b096addf9f62e65526f8ffad80e64c5db93
2010-10-11 14:58:48 -06:00
Subbaraman Narayanamurthy 1ea479ee8c [msm_shared/mmc]: Enable sD card detection and eMMC driver in apps boot
Dynamically detecting eMMC or sD card for eMMC targets. Removing the
temporary fix to enable early boot chain to load kernel and make apps
boot to do that.

For detecting sD, the following commands are sent during init and
identify phase. This happens @ 400KHZ and 1 bit mode.
CMD0, CMD8, ACMD41, CMD2, CMD3, CMD9, CMD7

After identifying the card and selecting the card, clock is increased
to 50MHZ and bus width is set to 4 bits. Card status is checked whether
it has entered transfer state before entering data transfer mode.

Change-Id: I91e27a2d065a7a0d7468e79ffc208cd64727fbff
2010-10-11 11:01:43 -07:00
Shashank Mittal c648e71d34 [msm8x60]: Fix LCDC display for new PXO plan.
- Add support for new PXO frequency plan.
    - Update splash image
    - Disable mdp after loading HLOS into the ram.

Change-Id: I35072af621bae881a623def67b4f02dab9102bf4
2010-10-08 17:48:03 -07:00
Linux Build Service Account 4ebc11c0a2 Merge "[platform/msm7x30]: Add code to enable USBH Core clock." 2010-10-07 22:24:58 -07:00
Chandan Uddaraju 0af3482a35 [platform/msm7x30]: Add code to enable USBH Core clock.
The USBH Core clock will be disabled in the modem bootloader. Add
proc comm call to enable this clock in the bootloader.

Change-Id: Ic25e9725973206bce1b8fa51dd461bbd9e0ce2df
2010-10-07 14:46:58 -07:00
Subbaraman Narayanamurthy ced976f2c1 [msm7x30]: Temporary fix for eMMC FFA to boot with sD card
As we don't detect sD card at present, temporarily disabling apps boot eMMC
driver from loading kernel and enable early boot chain to do that.

Change-Id: Ia090399a4ebd06fda1dbff71fa575ea82e600b1f
2010-10-07 11:56:27 -07:00
Shashank Mittal 11e04c61a9 [msm8x60]: Disable LCDC by default.
Change-Id: Idf8a09b075dbc05b30bad530eea0e120ceee349b
2010-10-06 17:14:46 -07:00
Shashank Mittal 402d0973aa [msm8x60]: Enable LCDC display for SURF and FFA devices
Enable LCDC display for MSM8660 SURF and FFA devices.

Change-Id: I74099c7fb8a06bb40d6663066588698ed69cfee0
2010-10-05 14:12:51 -07:00
Shashank Mittal c69512e8f7 [msm8x60] Add support to read platform id from EPROM
This code adds support for I2C driver. I2C driver is used to read
EPROM for detecting product id of msm8660 device.

Change-Id: I66bdfb827048ba9ac97d17a05bb138019f2d5be9
2010-10-05 11:10:29 -07:00
Linux Build Service Account 032f50a4d5 Merge "[msm_shared/mmc] Add persist partition in mmc partition table." 2010-10-05 05:10:18 -07:00
Shashank Mittal 920798e30d [msm_shared/mmc] Add persist partition in mmc partition table.
This change adds 3rd ext3 partition detected on device as persist
partition.

Change-Id: I04f4d0ee17e380190aa49f176bda658dddb02f6e
2010-10-04 17:21:32 -07:00
Ajay Dudani 7d60552e53 [msm7x30] Check local clock control state and enable hsusb clocks
In order to be compatible with modem versions that do not always grant
local clock control for usb to apps processor, we check the status
of hsusb core clock local clock control.  If we have local clock
control, we enable it ourselves using shadow register.  If not, then
make a proc comm to modem to enable the same.

Also included minor cleanup to move usb clock initializations to
platform specific area.

Change-Id: I1faac09a94e9b9402f06172d528b54ed6058f450
2010-10-04 16:46:07 -06:00
Linux Build Service Account 1e5cfc10cb Merge "[msm8x60]: Enable fastboot reboot for 8660." 2010-10-01 21:08:06 -07:00
Subbaraman Narayanamurthy c64727821c [msm8x60]: Enable fastboot reboot for 8660.
CRs-fixed: 257915
Change-Id: I5096dc60d6cfbdfe1e7754428a3d551528b954d0
2010-09-30 15:38:57 -07:00
Chandan Uddaraju c6cbd80adc [target/msm7625]: Add code to support 4k page nand devices.
1. Add code to dynamically configure the partition table to support
   2k and 4k page flash devices.
2. Increase the size of system partition needed for froyo builds.

Change-Id: I1048dfe4ee95257354a8145a1899dd7b680ae470
2010-09-29 00:33:09 -07:00
Ajay Dudani 3640a0a8fc [msm7630] Initialize CCPR register for L1/L2 cache coherency policy
Change-Id: I8921c3fd59c5e26d7dbc81d0fca6d6d17b5b3135
2010-09-27 10:29:55 -07:00
Linux Build Service Account 8412104f00 Merge "[platform/msm7x30]: Add code to bump up the ACPU clock." 2010-09-25 08:50:27 -07:00
Subbaraman Narayanamurthy 4b43c35653 [msm]: Dynamic detection of eMMC for 7x30
Dynamically detecting eMMC slot and initialization for 7x30 SURF/FFA.

Change-Id: Id05cdbaaa831a53f0980e29e66bb93324eee8ed7
2010-09-24 16:01:06 -07:00
Chandan Uddaraju 35f771808e [platform/msm7x30]: Add code to bump up the ACPU clock.
Add code to enable PLL2. Modify the clock source to use PLL2.
This will bump up the ACPU clock of 7x30/8x55 targets to
806MHz/1GHz.

Change-Id: I7be42a45dca8996cf6374982f982b078994a855c
2010-09-23 15:36:02 -07:00
Ajay Dudani 9539c2d9b2 [msm7630] Read osbl memory region as pass it over to kernel as new atag
Change-Id: Ib9eea9c7a3bf8a0e7e990e036a83ec394bc79101
2010-09-22 14:35:20 -07:00
Ajay Dudani dfef90be61 [msm7630] Update ram partition table header to reflect new type entry
RAM partition table in osbl has added a partition type entry which
helps distinguish modem boot, apps boot and HLOS memory regions.
Updating the header and code to reflect the same and use it.

Change-Id: I54c401b6282d9c95d89c5d5137c7c8cbd2d9fdb4
2010-09-22 10:23:30 -07:00
Linux Build Service Account 282d372d27 Merge "[msm8x55] Add support to recognize new chip id variant for 8x55" 2010-09-13 20:07:00 -07:00
Linux Build Service Account 4e5f9f7d97 Merge "[msm8660]: Enable support for 1G memory by dynamic detection." 2010-09-13 19:11:56 -07:00
Subbaraman Narayanamurthy 34d711770c [msm8660]: Enable support for 1G memory by dynamic detection.
Change-Id: I21fb7338896c861cd7a880ce41c68a6a05157ccf
2010-09-13 14:29:59 -07:00
Ajay Dudani 6507798287 [msm8x55] Add support to recognize new chip id variant for 8x55
Change-Id: I84d0b66595c9e6ce40ac5a8257e2912be7703c72
2010-09-12 23:56:43 -07:00
Shashank Mittal 3704083c8f [msm7x30]: Enable LCDC display for msm7x30 devices
-- Add code to configure Toshiba LCDC panels
-- Add support for MDP4 LCDC mode.

Change-Id: I3846a146b98d19038779d8088cf64becff087a89
2010-09-11 20:50:58 -06:00
Linux Build Service Account 3c1ec4ccf8 Merge "[qsd8650a]: Limit cpu frequency to 768 MHz" 2010-09-11 18:17:45 -07:00
Ajay Dudani 2511e6645d [msm7630] Increase system partition size to account for code bloat
This should eventually be reverted once we find the root cause of
system image size increase.

Change-Id: I0625c549bfa21a7d29bbba31a8dc6fffb59a3099
2010-09-11 02:11:47 -06:00
Subbaraman Narayanamurthy fbe13a068a [msm7630]: Enable emmc boot from apps bootloader.
- Enable emmc boot for loading kernel from apps bootloader which was
  earlier done from modem side.

Change-Id: I683aaaf7d53da5d6be8fe611f5d07d23d3c3db07
2010-09-10 12:15:10 -07:00
Bikas Gurung 6197c862e7 [qsd8650a]: Limit cpu frequency to 768 MHz
Switching to 1.2 GHz was causing stability issue during bootup on
some hardware variants. So limiting the frequecy to 768 MHz.

Change-Id: If9de8bc294f005eff65bd74b62e67c171fb27ea6
CRs-Fixed: 252072
2010-09-10 11:49:27 -07:00
Subbaraman Narayanamurthy 50d936fabe [msm8x60]: Turn ON debug LEDs in apps bootloader.
Change-Id: I9a07ff3c7aec8de571383e4029085bb83332fc05
2010-09-08 17:09:00 -07:00
Subbaraman Narayanamurthy f9b6e0d05f [msm8x60]: Autodetect 8660 SURF and FFA
Writing to Debug LED register and reading it back to detect SURF or FFA.
This is a workaround till we get EPROM enabled in the devices.

Change-Id: Id8416cd5330363ad9c89dd4656c62f9c0ce54ba0
2010-09-08 16:59:13 -07:00
Linux Build Service Account ef79c73757 Merge "[msm7630]: Enable the clock locally for USB." 2010-09-07 17:07:03 -07:00
Subbaraman Narayanamurthy 8ffe8e45be [msm7630]: Enable the clock locally for USB.
Early boot chain does not enable USB clock and apps bootloader enables it now.

Change-Id: I3fc8b8957d07eb4deac4f1a0391f374203c1ccd0
2010-09-07 15:06:42 -07:00
Bikas Gurung d48bd24728 [msm8x60]: Add support for fastboot erase.
Change-Id: I7ca19dbe4e8fbcc80a2dbb12d7b93b34c624719a
2010-09-04 20:00:57 -07:00
Ajay Dudani 26cde0600a [msm7627] Reduce size of cache partition, increase system
cache partition is used during nand firmware image upgrade process
to share update images between recovery and bootloader.  Reducing
size of this partition down to free up more space for 'userdata'
partition.  One will have to increase this partition size back up again
if modem firmware image upgrade is to be supported on this target.

Increase system partition to make it consistent with other nand
based targets and to account for some code size increase.

Change-Id: I4dbc337c6f1250c7e4555ea4efab616103acb8d1
2010-09-01 20:05:35 -07:00
Subbaraman Narayanamurthy c95b5b1111 [msm]: Check image size for emmc before write and align it to 512 bytes
- Check image size before writing images to emmc partitions.
- Round the image length to be 512 byte aligned.

Change-Id: I66f6273bfa2c6d36af58628794babd0430d2a88d
2010-08-31 16:04:38 -07:00
Ajay Dudani 0270463d98 [msm] Add eMMC partitions based on type to enable flashing them using fastboot
Change-Id: I6a1e0264a4d5d569fc77bd2f4241e30435e3bbb3
2010-08-31 12:58:05 -07:00
Linux Build Service Account b4f798490d Merge "[msm7630/DMM] : Reserve EBI-1 memory as unstable." 2010-08-30 18:37:45 -07:00
Linux Build Service Account 61c4e73330 Merge "[msm7627]: Change ACPU clock value" 2010-08-30 15:45:46 -07:00
Subbaraman Narayanamurthy bc0890302b [msm7627]: Change ACPU clock value
Change ACPU to 600/800 MHZ after detecting dynamically.

Change-Id: Id458900edfcad87aec456fa7fb027b5f69744df1
2010-08-30 11:47:32 -07:00
Linux Build Service Account 360899f74e Merge "[target/qsd8250]: Add support to represent partition size in MB" 2010-08-29 17:24:58 -07:00
Linux Build Service Account e6bea2b4d5 Merge "[msm8x60]: Add code to vote for PLL8 before configuring USB clock" 2010-08-28 13:18:11 -07:00
Karthik Parsha b26c956260 [msm7630/DMM] : Reserve EBI-1 memory as unstable.
Change-Id: I1041d2aa26ba6c74a8b7f4d0f88d25e4022d8072
2010-08-27 11:16:49 -07:00
Ajay Dudani 7298b63ead [target/qsd8250]: Add support to represent partition size in MB
Add code to dynamically configure the partition table using
the flash page size information and represent the sizes in MB
instead of blocks.  This makes it easier to read and recalculate
the block for partition if we detect that we are running on a
4K page nand device.

Change-Id: Ic7477e220ba714c29a0f3e66f7874e9b16846fa7
2010-08-25 21:47:11 -07:00
Subbaraman Narayanamurthy 6e5ba4221d [msm7627]: Do not set boot image size in header
This change enables emmc driver in appsbl to load boot.img
instead of relying on boot chain to load it for appsbl as earlier.

Change-Id: Icb1f31f120f7e271cc95336cab3f7dcb674cd5a1
2010-08-25 19:21:51 -07:00
Subbaraman Narayanamurthy 88aa13dfbd [msm]: Add other FAT partition type for modem
Change-Id: I196cd7f21a656c6be4517e9b5a25f95966888008
2010-08-25 19:20:52 -07:00
Shashank Mittal 237301cc79 [msm8x60]: Add code to vote for PLL8 before configuring USB clock
Change-Id: I5230482b53ffd38cda92ceb9291a2b3116231ed2
2010-08-25 10:48:00 -07:00
Ajay Dudani 2676ea9fa2 msm7627: Enable eMMC boot support
Change-Id: Ieda593ce52f87598c869e4270d55670889805d72
2010-08-21 17:40:45 -06:00
Chandan Uddaraju 49fd643a08 [target/(msm7627/qsd8250)]: Update to splash and persist partitions.
1. The splash image is in the form of an array. The splash partition present
   in the ptable is not needed anymore.
2. Interchange the foreground and background color for splash screen display.
3. Fix the persist partition size. Use integer values for the persist partition
   size.

Change-Id: Ib41f4686be6d5762508e312f04416bf2cbb796f4
2010-08-12 13:36:18 -07:00
Chandan Uddaraju 406051184a [platform/msm_shared]: Fix the number of Nand Blocks generation.
Correct the supported flash devices array entries for two nand chips.
Use the correct supported flash devices array to fix the generation
of number of nand blocks present on the flash chip.

Change-Id: I7eabab5a2df28ffef0d4bc79c825401d78399bb8
2010-08-10 07:31:20 -07:00
Linux Build Service Account 117e82db64 Merge "[target]: Add code to use splash image as a character array" 2010-08-10 02:39:27 -07:00
Linux Build Service Account 7bf05036b9 Merge "[msm_shared/nand]: Fix bad-block calculation for flash read" 2010-08-10 02:39:26 -07:00
Chandan Uddaraju 40b227df7c [target]: Add code to use splash image as a character array
Represent the splash image in the form of a character array.
Use this array instead of reading the splash image from nand device.
Reduce the debug messages that are displayed on the screen.

The time taken by the bootloader is reduced by ~325ms with this change on
a MDDI display device.

Below are the steps/commands to convert the splash image into a character array:
1. $convert -depth 8 <splash image in PNG format> rgb:splash.raw
2. $host/linux-x86/bin/rgb2565 < ./splash.raw > final.img
3. $hexdump -C -v final.img | tr -s " " | cut -d ' ' -f2-17 | awk 'BEGIN {print "{"}
                {OFS=""; ORS=""; print "\t"; for(i=1; i <= NF; i++) print "0x"$i", "; print "\n";}
                END {print "}\n"}' > array.txt

Change-Id: If3d1752939cba7e843c1b8a350c40bb0d92b27c4
2010-08-08 20:14:13 -07:00
David Ng 77849d39cd [msm] Add fastboot flash modem partition support for eMMC
Change-Id: Id9ef8cb62703bc39da5d785c7654b438b740eea9
2010-08-04 16:01:05 -07:00
Shashank Mittal fd1f04fbf9 [msm_shared/nand]: Fix bad-block calculation for flash read
Fix calculation of offset according to bad blocks present before the
current page.

Without this change flash read would fail if number of bad blocks before
current_block are more than or equal to difference between current_block
and start_block.

Change-Id: I3c68639a534c0e1ede9c6152b9c0094baede6b55
2010-08-04 13:52:14 -07:00
Linux Build Service Account 22020b1673 Merge "[target/msm7627]: Add support for 4k page nand devices." 2010-07-30 20:38:20 -07:00
Linux Build Service Account 26ae33b780 Merge "msm7627: Update to use ram partition table for apps memory map" 2010-07-30 20:38:19 -07:00
Chandan Uddaraju a7e8ffe32e [target/msm7627]: Add support for 4k page nand devices.
Add code to dynamically configure the partition table using
the flash page size information.
Increase the system partition size needed for android 2.2 builds.

Change-Id: I9b3623b054ac1c548224b817d25e92733b3f277b
2010-07-30 20:11:07 -06:00
Ajay Dudani f12dd7133b msm7627: Update to use ram partition table for apps memory map
Similar to 7x30, use ram partition table on 7x27 as well.  However,
the ram partition table currently reports some extra memory as usable
by apps - so we adjust for this until that gets fixed.

Change-Id: I3e22c7304e4866e48db459cb6b285ba438c9eff3
2010-07-30 18:49:40 -07:00
David Ng f773dde730 [msm] Enable battery charging flag based on power-on status
Determine power-on reason (e.g. due to USB cable connection,
button press, etc.) and pass androidboot.battchg_pause to kernel.

Enable flag on msm7627_* targets when power-on due to USB
cable connection.  This will trigger a pause during bootup
until user keypad input.

Change-Id: I7751d9d7bdd0e735cd5cdeeedb952879cb237005
2010-07-30 13:49:15 -07:00
Subbaraman Narayanamurthy eb92bccce2 [app/aboot]: Add recovery and update support in froyo.
- Read radio.img from Cache partition and write it to FOTA partition.
- Changed partition size for Cache and added misc partition for recovery.
- Changed product name for fastboot update.

Change-Id: I831b2bb757865a0a4108cab66950691d5db9b8b2
2010-07-28 11:48:58 -07:00
Chandan Uddaraju 61e6d7c8ed [platform]: Add code to optimize the mddi display intialization.
Add code to replace thread_sleep calls with mdelay functions to avoid
the context switch delays while initializing the mddi panel.

Change-Id: Ibf0686b0ab01bd41f40e049cdf9415e52f8a5cf1
2010-07-20 18:22:00 -07:00
Chandan Uddaraju 07644859a1 [target]: Fix LCDC panel configuration macros for all targets
Add code to move the LCDC panel configuration macros to target specific
display.h files.

Change-Id: Ie2551592a89c1ae20da447a97ac7e6d56e337547
2010-07-14 12:43:14 -07:00
Chandan Uddaraju 2943fd6d1f [msm]: Enable display driver by default for splash screen on 7627 & 8650
If rgb565 image is available in splash partition then display it
as splash screen.

On Linux, splash.img can be created as follows:
convert -depth 8 splash.png rgb:- | out/host/linux-x86/bin/rgb2565  > splash.img

Change-Id: I24b61cbc94af4bac14b9a49b030b59484a0b283e
2010-07-14 06:45:31 -07:00
Ajay Dudani 5e856b5bc2 [msm] Update ramdisk and scratch address for 7x27 and 8x50
scratch address overlapping with ramdisk address potentially breaks
'fastboot boot boot.img'.  Fixing ramdisk to be consistent with offsets
as expected in mkbootimg and make sure it does not overlap with scratch.

Change-Id: Ieb3529b15becd885044c53b23c7c490f6ae3a859
2010-07-12 14:28:43 -07:00
Linux Build Service Account 7e6b873e41 Merge "[msm] Update smem to be 8 byte align to match with everything around us" 2010-07-12 12:18:08 -07:00
Linux Build Service Account 20cb70a047 Merge "[target/msm7630]: Add code to auto detect interleaved mode." 2010-07-08 22:31:52 -07:00
Ajay Dudani c78b36f2f7 [msm] Update smem to be 8 byte align to match with everything around us
Change-Id: Ic9d60ca34f03726a5377cafe1ed864ab2fae7e02
CRs-Fixed: 245352
2010-07-08 19:36:27 -07:00
Ajay Dudani bf669d5b18 [qsd8250] Fix delays between bumping up Scorpion clock frequency
The delays between bumping up Scorpion clock frequency are of the
order of usec, but were incorrectly using thread_sleep which adds
delays in order of msec.  Updating the delays by rounding them up
to 1 ms and continue to use thread_sleep.

Change-Id: Ida89ef2de80075a1d8042493bac606080a99417b
2010-07-08 13:21:23 -07:00
Ajay Dudani 083d0dd17e [msm] Do not use stack before cpu_early_init for Scorpion targets
Also, reenable setting up of link stack for a predictable startup
environment.

Change-Id: I412aec6e4d2e1442020e40ae75df9ca5d3facfe0
2010-07-08 13:16:13 -07:00
Ajay Dudani 9e0d04fce2 [lk] Do not force cortex targets to be compiled as arm11
Change-Id: If9649aadcd1b18b8adcba68e51f25a9483acc89d
2010-07-08 11:42:11 -07:00
Chandan Uddaraju 14e57eb2fc [target/msm7630]: Add code to auto detect interleaved mode.
Interleaved mode is identified using the build id provided
in shared memory. Configure the ptable entries for interleaved mode.
Configure GPIOs for the second NAND device. Add code to modify
the page size when operating in interleaved mode.

Change-Id: Ic1bbabc32b15ef0d17b52c89b1dcc639c0fef5ae
2010-07-07 14:48:11 -07:00
Linux Build Service Account 8b3ddd2ecc Merge "[atags.c]: Added support for 512MB in 8660." 2010-07-07 11:01:38 -07:00
Subbaraman Narayanamurthy e2e081c344 [atags.c]: Added support for 512MB in 8660.
Change-Id: I0c3f3825557a3171f8e9bb815f084c6d3b9384ed
2010-07-02 18:22:41 -07:00
Shashank Mittal ec498ac053 [msm7x30]: Disable predecode repair cache for Halcyon V1
Change-Id: I46aca21f36d2fb6735ec3be9a1a3eecc49f78e36
2010-07-02 14:23:38 -07:00
Ajay Dudani 452f26f28c Revert "msm: Update arm cortex cache enable/disable"
This reverts commit 644810a111.
2010-07-02 13:42:43 -07:00
Ajay Dudani 644810a111 msm: Update arm cortex cache enable/disable
enable/disable caches even if already enabled/disabled.
Also, disable caches before reenabling them.

Change-Id: I1a9668402187d2254955256d6471d4980a4a2945
2010-07-02 05:14:47 -06:00
repo sync 67e957ba0e Fix 'mount' issues with persist partition for Nandwrite
Change-Id: I6e598bf60ca53b8eea2da8a8b1f9a1dd237dcace
2010-06-28 16:59:47 -07:00
Ajay Dudani 7e2fc3a598 [msm7627] Add support for msm7627_7k product based on msm7627
Change-Id: I12c1ed17d6e25b84fab79bb7b6a63c17ec5ebf16
2010-06-17 07:46:17 -07:00
Ajay Dudani faa5b6eec4 Revert "bootloadker/lk: Changes for adding new target msm7627_7x to build system"
This reverts commit ce64f5195f.
2010-06-17 07:44:15 -07:00
Vasantha Kumar ce64f5195f bootloadker/lk: Changes for adding new target msm7627_7x to build system
Change-Id: Ifb440a33fa13b7f41090f4d192a570fc487820fa
2010-06-15 15:51:38 -07:00
Shashank Mittal d8c42bf9ae [qsd8650a_st1x] With USB connection force device into fastboot mode.
With this change during bootup, if USB is connected to the device then LK goes into
fastboot mode, no matter if boot.img is preset or not.

Minor code cleanup in aboot.c

Change-Id: I3a074321ec3802f5518f42b3b27d4d45c0577905
2010-06-10 14:40:54 -07:00
Ajay Dudani e26c8c7c5c Merge "[target/msm8660_surf]: Add keypad driver support." 2010-06-09 10:28:36 -07:00
Chandan Uddaraju bedca15aec [target/msm8660_surf]: Add keypad driver support.
Add code to interface with PMIC SSBI arbiter registers to scan keypad for
msm8660 target. Add two additional functions to read, write and configure
the PMIC gpios used for keypad. Add code to use different read/write functions
for PMIC SSBI2 interface for msm7630 and PMIC arbiter wrapper interface for
msm8660 target.

Change-Id: Idde16232785dfc06728dea29c05b99251e45ba9f
2010-06-09 00:37:59 -07:00
Ajay Dudani 12ca47ad50 Merge "[qsd8650a_st1x] Remove non functional keypad driver for ST1.x target" 2010-06-08 08:04:46 -07:00
Ajay Dudani c3dadded51 [qsd8650a_st1x] Remove non functional keypad driver for ST1.x target
Change-Id: I958412ae1c3f166da8147495b8a6a60c8dc5a005
2010-06-08 06:52:53 -07:00
Shashank Mittal 7afbf28749 [eMMC]: Make eMMC read and write faster in LK.
-- Fix the buffer size
 -- Add support to read and write mutiple words at a time
 -- Reduce number of checks for errors.
 -- Increase sdc clock speed for msm8x60

Change-Id: Ied6b6379d9b6d46ed9c4abd8ae1d6ab459ba18a3
2010-06-03 18:02:03 -07:00
Shashank Mittal fc317cf851 [msm8x60]: Fix scratch address for new memory map change.
Change-Id: I99779bcb1c3d7703b1df2a54d4044cad74ec3550
2010-06-02 11:05:50 -07:00
Ajay Dudani 3ab976f781 [msm] Update scratch address for ramloading to match T32 scripts
Change-Id: I2e3493a02cd2a61e7e648b315ec6ed90a940332e
2010-06-01 14:00:25 -07:00
Ajay Dudani 0a10a18875 Merge "[msm8660] Update memory atags to reflect new memory map" 2010-05-27 07:32:37 -07:00
Ajay Dudani 62837eca9f Merge "[msm] Generate emmc_appsboot.mbn in addition to EMMCBOOT.MBN" 2010-05-27 07:31:32 -07:00
Ajay Dudani ac5cc75533 Merge "[msm] Query scratch address for jtag flashing tools" 2010-05-27 07:31:25 -07:00
Ajay Dudani ad8efd9da6 Merge "[qsd8650a] Add initial support for qsd8650a chipset" 2010-05-27 07:31:10 -07:00
Ajay Dudani b3af4173c2 [msm8660] Update memory atags to reflect new memory map
Change-Id: I10504d33404df988af656cde96a607367fb3fc29
2010-05-27 00:46:27 -07:00
Ajay Dudani 513fb7486a [qsd8650a] Add initial support for qsd8650a chipset
Change-Id: I071c296f38f8ced90c089572c4d763381a695bfe
2010-05-27 00:37:57 -07:00
Ajay Dudani 3abd6b7c1b [msm] Generate emmc_appsboot.mbn in addition to EMMCBOOT.MBN
Modem builds for different targets are in process of changing naming
from emmc_appsboot.mbn to EMMCBOOT.MBN.  Generating both images
until transition to EMMCBOOT.MBN is complete for emmc boot targets.

Change-Id: I903cdd3457c7bd31f1cfa71bee18e33fd67b6d85
2010-05-26 16:08:19 -07:00
Ajay Dudani b5f9e50e2a [msm] Query scratch address for jtag flashing tools
Remove dependency on 7x30 build id to get scratch address; we already do
this for 'fastboot' case.

Change-Id: Iaa70a7aab9af1e494f94c50f0154472a45db1bc1
2010-05-26 15:14:24 -07:00
Ajay Dudani afc2cf5125 [msm] Update emmc_appsboot.mbn to EMMCBOOT.MBN
The modem bootloaders now look for EMMCBOOT.MBN instead of
emmc_appsboot.mbn for eMMC targets

Change-Id: I3a8a35bb83cba2d7429ff66192168e43a91f1504
2010-05-25 20:35:09 -07:00
Chandan Uddaraju d086459d75 [target/msm7630]: Add new Mach ids for SVLTE devices
New hardware platform type is provided in the Shared memory of the
SVLTE device. At present, we only support FFA varients of these
devices. Add code to read the new hardware platform and provide
the new Mach ID to the kernel.

Change-Id: Ic129543e8ef651f649bd3382682b5c2d66f8a044
2010-05-23 21:09:15 -07:00
Shashank Mittal 23b8f42e38 [msm8x60]: Add support for msm8x60 in LK
-- Adds new project for msm8660_surf
-- Adds new platform for msm8x60
-- Adds support for Generic Interrupt Controller (GIC)

Change-Id: Ide4baba25dad6b799f835a29ea158035ab8f5ff0
2010-05-14 14:12:49 -07:00
Shashank Mittal 52525ff79f eMMC: Add support for MMC driver in bootloader.
This change adds eMMC driver support in LK bootloader.

Change-Id: I2616fdd5c2938791a9658b117c92cf33fffdd9c5
2010-05-01 15:29:37 -07:00
Ajay Dudani ecb72205af Merge "[target/msm7630]: Add code to dynamically configure page table entries." 2010-04-29 08:46:27 -07:00
Ajay Dudani a1eafc4c61 [msm7630] Add support to detect physical memory usable by apps proc
Modem bootloader places information about physical memory regions
that are usable by apps in shared memory.  This information is available
in shared memory before apps processor is brought out of reset.

Add support to read this "ram partition table" and check for physical
memory chunks that are set as read/write for apps processor, exclude the
apps bootloader area and give the rest to Linux kernel using atags.

As a result, if modem physical memory requirement reduces, then apps
bootloader does not have to change.  Apps can pick up the extra memory
made available by detecting this from ram partition table.

Change-Id: I6abd85cd57710ceda89d4f125e3dffc59e7078b7
2010-04-22 15:11:11 -07:00
Ajay Dudani 79d0d405d3 [7x30] Update write to PVR2F0 when initializing cache settings
Original code intended to write to PVR2F0 as commented, but was
incorrectly writing to PVR2F2 instead which affects L1 D cache
read timing. Fixing to write to PVR2F0 as was originally intended.

Also adding data and instruction synchronization after zeroing
bss to force context ordering before jumping to kmain.

Change-Id: Ibdfffd5bad33fa7bfe068fb743fec0cbec97ece8
2010-04-21 17:38:14 -07:00
Chandan Uddaraju d56669ff17 [target/msm7630]: Add code to dynamically configure page table entries.
Add code to support 2k and 4k page flash devices by configuring the
ptable entries according to the page size. Add code to correct one
of the supported flash-devices table entry.

Change-Id: Id222180a347fafe083dda479d07956493b2b2858
2010-04-20 11:35:44 -07:00
Ajay Dudani c51bf63c3e [7x30] Updates for new memory map
* Move apps bootloader back to zero
* Move shared memory base to 1M
* Memory tags change to reflect new blocks of memory now available to kernel

Change-Id: Id0fb5aa4f9c4a6bc5ee40880fe3ebd506e33abab
2010-04-15 10:41:23 -07:00
Ajay Dudani 03900fe2d0 Merge "Add interleave support in android boot loader nand driver." 2010-04-13 09:24:36 -07:00
QuIC Gerrit Code Review aa4b304f7a Merge change I296aea27
* changes:
  [keys/msm7630]: Remove the syncronization with mARM for PMIC GPIOs.
2010-04-01 19:34:01 -07:00
Chandan Uddaraju a7cb0f49b0 [keys/msm7630]: Remove the syncronization with mARM for PMIC GPIOs.
The PMIC GPIOs are now configured in the mARM boot code before the scorpion
is released from reset. Remove the code that waits for the AMSS initializtion
to complete.

Change-Id: I296aea27fa199898bb6efa08b590e3664a643679
2010-04-01 17:18:00 -07:00
QuIC Gerrit Code Review 10c20702ee Merge change I469143ec
* changes:
  [msm7x30]: Fix shared memory base address
2010-04-01 15:23:47 -07:00
QuIC Gerrit Code Review 0e0f2cf6ad Merge change Icd0d8602
* changes:
  [target/msm7630]: Add code to increase the total memory by 6M for normal nand boot.
2010-03-31 20:10:33 -07:00
QuIC Gerrit Code Review c87c62704c Merge change I5fe2d0db
* changes:
  [msm7630_fusion]: Add msm7630_fusion target for lk bootloader
2010-03-31 18:48:18 -07:00
Chandan Uddaraju a71835f062 [target/msm7630]: Add code to increase the total memory by 6M for normal nand boot.
Add code to reclaim the efs RAM partition of EMMC for nand boot.

Change-Id: Icd0d8602fdda7baf0dcd1f92e70f96c9dfb4d639
2010-03-31 18:17:16 -07:00
Chandan Uddaraju b56cab56bb [platform/msm7630]: Add "DSB" before "ISB" instruction to fix boot up issues
Add DSB instruction to make sure that all the memory access instructions
before this instruction are completed. This will fix boot up issues on
few Version 2 devices.

Change-Id: I34fbc221a81e65ba54339fd8bc0efce2b9cff669
2010-03-28 20:06:57 -07:00
Chandan Uddaraju 385081b0bd [platform/msm7x30]: Add ISB instruction after updating Cache settings.
Add code replace delay loop with ISB instruction after updating
the L1 and L2 Cache settings.

Change-Id: I35a2c063e3b2dec596e4b07a2b018a75267104a7
CR-Fixed: 230511
2010-03-28 00:38:10 -07:00
Sridhar Parasuram 60bee03c1a [msm7630_fusion]: Add msm7630_fusion target for lk bootloader
This target uses the same apps as 7x30.

Change-Id: I5fe2d0db7db131dd33351f97775bb05148150b53
2010-03-26 07:49:12 -06:00
David Ng 56936764b4 msm7630: Use 19.2MHz for DG timer/scheduling for eMMC boot
Change-Id: I7092619de6fa45a61a2cdbf7ede68d390700e528
2010-03-25 19:50:32 -07:00
QuIC Gerrit Code Review a7368bdb92 Merge change Ic5ec30e2
* changes:
  [target/msm7630]: Change MACH IDs for 8x55_surf and 8x55_ffa targets.
2010-03-22 19:16:34 -07:00
Shashank Mittal 9ff3316a1a [msm7x30]: Fix shared memory base address
With new memory map changes, shared memory is moved from 0x00000000 to
0x03700000.

Change-Id: I469143ec558ae23a7f992253aae6000bc1996b12
2010-03-22 18:07:12 -07:00
Chandan Uddaraju 26d5b7b54d [target/msm7630]: Change MACH IDs for 8x55_surf and 8x55_ffa targets.
Change-Id: Ic5ec30e2455ade58486cee0d855aa92a0bd1e051
2010-03-22 17:18:40 -07:00
QuIC Gerrit Code Review ee28782c7e Merge change I17855af0
* changes:
  [target/qsd8250]: Fix the macro named used for 512MB RAM support.
2010-03-22 15:20:22 -07:00
QuIC Gerrit Code Review d1009cb58c Merge change I188ed5c3
* changes:
  [timer]: Fix thread scheduling according to Debug timer frequency.
2010-03-22 15:20:19 -07:00
QuIC Gerrit Code Review 790a6105d1 Merge change I98be2d63
* changes:
  msm7630: Get around boot up issue on some v2 hardware
2010-03-22 15:20:14 -07:00
Ajay Dudani ac77c9a04d msm7630: Get around boot up issue on some v2 hardware
On some v2 hardware, we see Scorpion aborts execution.  Additional delay
after cache amp settings helps these hardware to continue to boot up.

This is the current workaround until we find the root cause.

Change-Id: I98be2d6301e81fa4e6994bde3966cfb30189651a
2010-03-22 13:02:23 -07:00
QuIC Gerrit Code Review 7784d500a6 Merge change I5e44500a
* changes:
  [app/aboot]: Fix "fastboot boot" issue on 7x30 target.
2010-03-20 08:46:11 -07:00
Chandan Uddaraju 1679e685a5 [timer]: Fix thread scheduling according to Debug timer frequency.
Add code to configure thread scheduling according to the
frequency at which debug timer is configured for each target.

CRs-Fixed: 228733

Change-Id: I188ed5c3500ba88a4176929c1eb3d6fcf8b94823
2010-03-19 16:50:12 -07:00
Chandan Uddaraju 1f6030f388 [app/aboot]: Fix "fastboot boot" issue on 7x30 target.
Add code to use the correct page size in "fastboot boot" command
handler.

Change-Id: I5e44500a9a780e99afb13912dd1ca17ce288767a
2010-03-19 13:26:38 -07:00
Murali Nalajala a8c94c69b3 Add interleave support in android boot loader nand driver.
Add interleave support in android boot loader nand driver.
2010-03-19 17:07:13 +05:30
Chandan Uddaraju f759be3623 [target/msm7630]: Add support for msm8x55 target in apps bootloader.
Add code to use the msm_id to differenciate between 7x30 and
8x55 targets. Add new Machine ids for surf and ffa for 8x55 that will be passed
to the kernel after reading the msm_id.

Change-Id: I1fd8378f5ab65480228b3b4a6a8c7e35421cc7cc
2010-03-18 12:45:42 -07:00
Chandan Uddaraju 16a19f1f6b [target/qsd8250]: Fix the macro named used for 512MB RAM support.
Change-Id: I17855af02c9e17065f563831731f51771c010794
2010-03-18 12:39:46 -07:00
Chandan Uddaraju 1434a60d99 [target/msm7630]: Add support for smem version 4.
Add platform_version variable to the new  SOC v4 structure.
Add additional variable for alignment.

Change-Id: I6e677b04b704d3887c703061644b4e636e9c0f4a
2010-03-16 11:28:37 -07:00
Chandan Uddaraju 662928297f [platform]: Initialize ADFSR and EFSR to 0 during bootup.
Initialize the scorpion co processor registers ADFSR and EFSR
to zero.

Change-Id: I24ae1c8fca2bdd6b40c73eceb701148265503d22
2010-03-11 18:07:42 -08:00
Shashank Mittal 8e49dec9ed LK: Add support to write on modem partition
Modem nand layout is different from Android nand layout. This change
updates lk nand driver to write on modem nand partitions.
2010-03-08 16:53:35 -08:00
Ajay Dudani a6c845b287 [msm7x30]: Fix fuse address and reading procedure to determine correct values for CP15 registers
There is a change from Raptor to Halcyon in terms of number of fuse and
addresses of these fuses. This change fixes scorpion initialization for
7x30 target.

CRs-Fixed: 228229
2010-03-03 18:46:51 -08:00
Ajay Dudani d8a91a8838 msm: Update L2CR1 settings based on performance benchmark settings
This change improves the following LMBench benchmarks by over 15%

System Call Latency
Signal Handling Latency
Fault Latency
Inter-process Communication Latency
Inter-process Communication Bandwidth
Random Number Generation Latency
2010-03-01 20:01:53 -08:00
Chandan Uddaraju d6d4504c8e [aboot:fastboot]: Add code to fix 'mount' issues with persist partition 2010-02-24 21:12:45 -08:00
Chandan Uddaraju 2aba273fb1 [keypad/msm7630]: Fix the bootup issue while trying to do soft reset using Jtag
During soft reset using Jtag, the device goes into fastboot mode.
The key scanner is detecting all the keys in a particular row as pressed.
The fix filters this condition where the key scanner reports that
all keys in the row are pressed at the same time.

CRs-Fixed: 227799
2010-02-24 14:34:41 -08:00
Ajay Dudani cd01f9be94 lk: Change boot.img header offset based on LK address for eMMC 2010-02-23 21:13:04 -08:00
Shashank Mittal 024c033438 Recovery: Add support in lk to read/write recovery messages.
Add support in bootloader to intract with recovery code.
2010-02-23 16:59:40 -08:00
David Ng db6b6a8b02 lk: Disable IRQ/FIQ during bootup on Scorpion
Set I/F flags (disable IRQ/FIQ) in early stage of bootloader for
Scorpion-based MSM 7X30 and QSD 8X50.  This applies to both cold-
and warm-boot.
2010-02-23 09:25:47 -08:00
QuIC Gerrit Code Review 355ef63780 Merge change I28a2d8dd
* changes:
  msm7625: Workaround for a H/W bug in 7x25.
2010-02-12 09:08:35 -08:00
Ajay Dudani d43419e2ea msm: Update partition tables to give additional 10M to system partition
Bringing in new apps with 3D Gallery, Live Wallpapers, Launcher2
is causing system partition to grow. Increase the buffer size in fastboot
mode from 100MB to 120MB.
2010-02-11 14:28:26 -08:00
Manas Abichandani a3898ff2fb msm7625: Workaround for a H/W bug in 7x25.
There is a h/w bug in 7x25 due to which sometimes PLL2 does not work
properly. So we use PLL3 instead which internally uses PLL2 but this
works fine.

CR-fixed: 221986
2010-02-10 16:31:30 -08:00
Chandan Uddaraju a342574576 [msm7630]: Add code to scan limited number of keys of Qwerty keypad.
Add code to scan only the common keys present on all the different
varients of msm7630 target. This fixes the issue of device not going
into fastboot when miniSD card is present in a Fluid device.

CRs-fixed: 225917
2010-02-09 22:45:33 -08:00
David Ng 3679bc5fb1 fastboot: Allow runtime decision on memory scratch space
Different flavors of one target may require different memory
regions to be used for storing images in RAM during fastboot
flashing.  Allow the scratch space to be decided based on
runtime detection.

For msm7x30, use the 2nd memory region (with starting address
dependent on LPDDR1 or LPDDR2) as scratch space.
2010-02-09 15:43:43 -08:00
QuIC Gerrit Code Review d695d15a34 Merge change I481a23b9
* changes:
  [msm7630_surf]: Add key mapping to boot into recovery mode.
2010-02-09 08:11:52 -08:00
David Ng 6e1711f21c msm7630: Update for new memory map
New memory map for msm7630 with apps bootloader starting at
0x00100000 (1MB) and shared memory at 0x0.

Add new command "loadaddr:" to nandwrite for querying
the load address of images for flashing.  This allows the
target to respond with the second/larger memory segment
in order to accommodate larger images.
2010-02-08 18:36:13 -08:00
Chandan Uddaraju 481a23b9a7 [msm7630_surf]: Add key mapping to boot into recovery mode.
Add R+ key to boot into recovery mode for msm7630_surf target.
2010-02-08 11:38:09 -08:00
Chandan Uddaraju 7f5b901386 [qsd8250]: Add usb charging support in LK bootloader.
Add usb battery charging support for qsd8250_surf and qsd8250_ffa
targets in lk bootloader. USB charging is enabled only when
device goes into fastboot mode.
2010-02-06 16:48:41 -08:00
QuIC Gerrit Code Review 4e4834e49f Merge change Id3275cd7
* changes:
  LK: Add support for splash screen on MSM7627_SURF
2010-02-02 09:22:55 -08:00
David Ng 671b53f1ce msm7630: Remove build ID check for eMMC
eMMC is based on compile time flag and runtime checking
of eMMC boot based on build ID can cause failure.
2010-02-01 20:50:42 -08:00
Shashank Mittal 4f99a88131 LK: Add support for splash screen on MSM7627_SURF
Moving lcdc.c file from qsd8k and msm7x30 to msm_shared under platform
directory.
2010-02-01 18:04:43 -08:00
Chandan Uddaraju 535fa09d69 [target/[msm7630,msm7627]]: Increase persist partition size needed for yaffs2. 2010-01-28 10:03:25 -08:00
Chandan Uddaraju 11f59e99eb Revert "[platform/msm7x30]: Reconfigure EBI2 to add support for Ethernet"
This reverts commit b2aef503ff.
2010-01-27 12:28:15 -08:00
Chandan Uddaraju cc400c211a [target/[msm7627,msm7630,qsd8250]: Increase system partition size needed for Android 2.1 upgrade.
Increase the system partition size to 85MB for msm7627_surf, msm7627_ffa,
qsd8250_surf and qsd8250_ffa targets.
Increase the system partition size to 95MB for msm7630 target.
Add code to select the userdata size dynamically during run time for qsd8250_surf
and qsd8250_ffa targets.
2010-01-22 17:19:09 -08:00
QuIC Gerrit Code Review 21d155584c Merge change I9fb19ceb
* changes:
  Revert "[qsd8250] Split 232MB for kernel into 224M + 8M"
2010-01-22 13:47:27 -08:00
QuIC Gerrit Code Review ac9991b9cc Merge change Icc8272ed
* changes:
  [msm] Update Copyright markings
2010-01-22 08:35:32 -08:00
QuIC Gerrit Code Review e71f14a88e Merge change I42460e6a
* changes:
  [target/[msm7627,msm7630]: Add persist partition and re-arange partition table.
2010-01-21 18:47:25 -08:00
Chandan Uddaraju 9e5ab966fa [target/[msm7627,msm7630]: Add persist partition and re-arange partition table.
Move recovery partition to the end.
Add persist partition to msm7627_surf, msm7627_ffa and msm7630_surf targets.
Make userdata partition to have variable length and add code to
allocate the remaining/leftover space on flash to userdata partition.
Correct the density value for 4k page nand device in the supported nand
devices array.
Increase the system partition for msm7630_surf target by 5MB.
2010-01-21 16:31:30 -08:00
Ajay Dudani c621bd03f5 [msm] Update Copyright markings 2010-01-21 10:03:16 -08:00
Michael Bohan b2aef503ff [platform/msm7x30]: Reconfigure EBI2 to add support for Ethernet
Set EBI2 CS5 to 'SMEM' and also increase the read /
write waitstates for CS5.  The added waitstates are required to
interact with the SMC9221 Ethernet controller properly.

The SMC9221 is only onboard the msm7x30 SURF and Fluid.  This
configuration should be benign on the FFA.
2010-01-21 09:49:59 -08:00
Ajay Dudani 57bd43a158 Revert "[qsd8250] Split 232MB for kernel into 224M + 8M"
This reverts commit d89e33c9f9.
2010-01-19 15:18:28 -08:00
QuIC Gerrit Code Review a7be71db69 Merge change I3eee0aba
* changes:
  [msm] Clear relevant status registers after write and erase.
2010-01-18 09:03:29 -08:00
Chandan Uddaraju 94183c01c2 [target]: Add support for "fastboot reboot" and "fastboot reboot-bootloader" for all targets.
Add recovery partition for msm7630_surf target. Add support for
'adb shell reboot recovery' and 'adb shell reboot bootloader' for
msm7630_surf target. Add 'RESET_CHIP' proc_comm support for all targets.
2010-01-15 15:13:59 -08:00
Murali Palnati c54d13aa2f [msm] Clear relevant status registers after write and erase.
If a Program or Erase operation fails with an OP_ERR (for example when
erasing a bad block or when programming a page in bad block), then an
immediate read operation on a page from good block too fails with the
same OP_ERR. This is because the device status register (in the NAND
flash device) still has the FAIL flag set. This flag gets updated only
when a program or erase operation happens successfully.

To prevent this, clear NANDC_FLASH_STATUS and NANDC_FLASH_READ_STATUS
registers after every nand write and erase operation.
2010-01-15 20:58:26 +05:30
QuIC Gerrit Code Review 99b7003e09 Merge change I5dcc8279
* changes:
  [platform/msm7x30]: Fix the Debug timer clock divider value according to hardware version.
2010-01-14 18:46:44 -08:00
Chandan Uddaraju 037b2264b2 [platform/msm7x30]: Fix the Debug timer clock divider value according to hardware version.
The Clock divider for Debug Timer is different for version 2 and version 1
for 7x30 target. Add code to read the hardware version and set the
divider accordingly.
2010-01-14 14:38:00 -08:00
Chandan Uddaraju 26a5690a4e [app/aboot]: Add additional key for fastboot mode.
This key is needed for FLUID device to boot into fastboot mode.
FLUID device will not have keypad.
2010-01-13 18:26:56 -08:00
QuIC Gerrit Code Review 960c43063a Merge change I96c50a53
* changes:
  Modified the paths to the bootloader to allow for debug build types as well as release build types.
2010-01-12 18:48:40 -08:00
Chandan Uddaraju 2e2908f909 [target/msm7630_surf]: Add code to increase the system and userdata partition. 2010-01-12 13:40:10 -08:00
Chandan Uddaraju e0adbdb222 [msm7625]: Add LK bootloader support for msm7625_surf and msm7625_ffa. 2010-01-09 23:12:46 -08:00
Chandan Uddaraju 98737de9ce [target/(msm7627,msm7630,qsd8250)]: Reduce the bootloader MEMSIZE macro to 1MB 2010-01-07 13:06:29 -08:00
Chandan Uddaraju 8a1d37ca72 [target/msm7627]: Fix size mismatch for recovery mode
Increase the size of BOOT_MODE field for msm7627_surf and msm7627_ffa
targets from 4 bytes to 8 bytes to match with the size present in shared memory.
2010-01-06 12:10:11 -08:00
Chandan Uddaraju de85d3f4ad [target/(msm7627,qsd8250)]: Add support to boot into recovery mode and bootloader fastboot mode
Add recovery partition in page table entry for 7627_surf and 7627_ffa targets.
Add code support to boot into recovery mode using the Home_key.
Add code support to boot into recovery and bootloader (fastboot) mode using adb shell reboot commands.
2010-01-05 16:32:33 -08:00
Dominic Binks 96c50a53f8 Modified the paths to the bootloader to allow for debug build types
as well as release build types.
2009-12-23 15:54:25 -08:00
Chandan Uddaraju 0ec5bb772a [qsd8250_ffa]: Fix nandwrite compiling issue. 2009-12-18 22:33:01 -08:00
Chandan Uddaraju d404d5a1b9 [target/msm7627_ffa]: Correct the base address of userdata in partition table. 2009-12-18 09:45:34 -08:00
QuIC Gerrit Code Review 41e5e4e5a2 Merge change I02a42409
* changes:
  [msm7627]: Replace thread_sleep calls and disable keypad initialization for nandwrite
2009-12-18 09:39:10 -08:00
QuIC Gerrit Code Review 0098b09bbc Merge change I96ec5981
* changes:
  [qsd8250]: Enable daisy chain flashing and fix nandwrite compiling issue.
2009-12-17 17:43:18 -08:00
Chandan Uddaraju 852cd2ce16 [msm7627]: Replace thread_sleep calls and disable keypad initialization for nandwrite
Disable keypad initialization for nandwrite. Replace thread_sleep calls with
mdelay.
2009-12-17 15:30:24 -08:00
QuIC Gerrit Code Review 2b0315b56f Merge change Ibba4ccaa
* changes:
  [nandwrite]: Disable bootstrap2 and app thread creation for nandwrite
2009-12-17 11:17:47 -08:00
QuIC Gerrit Code Review a29c75e83a Merge change I9650197f
* changes:
  [platform/msm7k]: Add code to wait till the mARM is ready to initialize the clocks
2009-12-17 11:17:36 -08:00
Chandan Uddaraju aeb979e059 [qsd8250]: Enable daisy chain flashing and fix nandwrite compiling issue.
Update makefile to fix nandwrite compiling issues.
Add ENABLE_NANDWRITE in list of defines for nandwrite makefiles.
Reduce the size of cache partition to 5MB from 76MB.
Disable keypad initialization for nandwrite.
Add recovery partition for surf and ffa.
2009-12-17 00:49:59 -08:00
Chandan Uddaraju bbec2b0c47 [nandwrite]: Disable bootstrap2 and app thread creation for nandwrite 2009-12-16 13:31:20 -08:00
Michael Bohan 19012bc0a8 Bootloader/lk: Don't disable L1 Data Cache on msm7x30
This was fixed on eclair-ohd, but never pulled over to lk.
2009-12-15 19:58:26 -08:00
Chandan Uddaraju 6cc1e3d6d9 [arch/arm]: Add code to disable warm boot for nandwrite 2009-12-15 15:21:06 -08:00
Chandan Uddaraju 9650197ffa [platform/msm7k]: Add code to wait till the mARM is ready to initialize the clocks
Before initializing the clock, wait for the modem to be ready. This will fix
the jload problem of not reaching the l4 entry point. Add code to not implement
this wait while flashing the apps images.
2009-12-14 23:24:21 -08:00
Chandan Uddaraju 241205063e [platform]: Add code to enable display initialization only in fastboot mode.
Add code for all targets to enable display only in fastboot mode.
Enable FB-debugging for qsd8k surf to see messages in fastboot mode.
2009-12-13 20:36:22 -08:00
Chandan Uddaraju a0d26dd2b5 [msm7630]: Add code to increase the system partition size to 78MB.
Add code to increase the system partition from 76MB to 78MB.
Disable keypad_init for nandwrite for 7x30.
2009-12-13 01:30:35 -08:00
QuIC Gerrit Code Review 9c081d0188 Merge change Ie5878661
* changes:
  [msm7627_surf/msm7627_ffa]: Add code to support flashing of images using jtag.
2009-12-13 01:08:22 -08:00
Chandan Uddaraju 56228923bc [msm7627_surf/msm7627_ffa]: Add code to support flashing of images using jtag.
Add code to modify the makefiles to compile for nandwrite.elf.
Modify the nandwrite to uninitialize interrupts, MMU, timers and cache
after flashing the image is completed.
2009-12-12 14:42:56 -08:00
Karthik Parsha 8f92a3046f [msm7x30] Add code to support Scorpion warm boot in lk bootloader
Before going into power collapse, the kernel does not change the reset vector, so execution resumes at bootloader.  Add check in bootloader to detect warm boot v/s cold boot and if warm boot is detected then jump to kernel after doing cpu early initializations.
2009-12-11 20:26:07 -08:00
QuIC Gerrit Code Review 68b7600120 Merge change I2b959b13
* changes:
  [qsd8250] Split 232MB for kernel into 224M + 8M
2009-12-11 15:45:49 -08:00
Ajay Dudani d89e33c9f9 [qsd8250] Split 232MB for kernel into 224M + 8M
Q6 image needs to be at 16M boundary; splitting the kernel memory
so we have two tags of 224M + 8M, before and after Q6 location.
2009-12-10 20:14:40 -08:00
David Ng 17fdc97aac lk: Fix nandwrite utility generation 2009-12-10 13:03:07 -08:00
David Ng bbeddbca5f lk: Fix msm7630_surf appsboot binary generation
Modify appsboot.mbn/emmc_appsboot.mbn such that the former
is only generated during non-eMMC compile and the latter
is only gnerated during eMMC compile.
2009-12-10 11:00:09 -08:00
David Ng bf2eb3c854 msm7627: Add support for eMMC boot for msm7627_surf and msm7627_ffa 2009-12-09 23:48:07 -08:00
David Ng 025c1d9880 lk: Add generic trigger support for eMMC boot
For targets that support eMMC bootup, defining
TARGET_USERIMAGES_USE_EXT2 will cause an eMMC apps
bootloader to be generated along with the NAND flash
apps bootloader.
2009-12-09 23:46:00 -08:00
Ajay Dudani 7d131cca9f [msm] clean out bootloader out before recompiling
make does not pick up the LK project for rebuilding unless appsboot.mbn
is missing.  Clean up stale objects to force recompile.
2009-12-09 01:06:21 -08:00
David Ng be536c3c12 lk: Fix issue with make not recompiling changes
Remove the target bootloader binary (appsboot.mbn) such
that source changes will trigger a recompile.
2009-12-08 12:26:21 -08:00
Ajay Dudani 168f6cb964 [msm] Add nandwrite to support flashing apps images over JTAG
Port over nandwrite from legacy to allow flashing of apps images
using JTAG.  nandwrite is an app in LK with its own project name that
runs in its own thread, just like aboot.  Just like aboot can accept
commands to flash images over usb, nandwrite accepts commands over
JTAG interface to allow flashing of apps images.
2009-12-07 19:10:40 -08:00
QuIC Gerrit Code Review 365f00d4ee Merge change I0c9f874f
* changes:
  lk: Add eMMC boot support
2009-12-07 18:59:01 -08:00
QuIC Gerrit Code Review 0f10193984 Merge change I71e28848
* changes:
  Ignore autogenerated mkheader binaries
2009-12-07 18:37:29 -08:00
David Ng 183a742929 lk: Add eMMC boot support 2009-12-07 18:21:21 -08:00
Ajay Dudani 513485f369 [msm7630] Update memory map to reduce 5M memory for Linux
Modem processor is reclaiming 5M from apps processor.  Update LPDDR1
and LPDDR2 memory configurations to reflect the same.
2009-12-07 15:38:01 -08:00
Nasser Grainawi 71e28848a1 Ignore autogenerated mkheader binaries
Signed-off-by: Nasser Grainawi <nasserg@quicinc.com>
2009-12-07 15:27:54 -07:00
Ajay Dudani 3337ebb17e [msm7630_surf] Add code to support lpddr2 surf
Detect LPDDR1 v/s LPDDR2 based on information from shared memory and
construct memory atags for kernel accordingly

Memory map differences:
LPDDR1 config has 195M contigious memory allocated to Linux kernel
LPDDR2 config has two blocks -- 123M+72M allocated to Linux kernel
2009-12-06 21:02:42 -08:00
QuIC Gerrit Code Review 4b67b56afe Merge change I86e1b420
* changes:
  [msm] Update density values for supported 16 bit nand devices
2009-12-05 16:32:13 -08:00
Ajay Dudani 3400d80b9c [qsd8250_ffa] Update userdata partition for qsd8250_ffa
On some ffa targets, noticed this userdata is too large.  Reducing size
of userdata until we know the lowest common denominator for FFA flash
size or start calculating the size based on device id.
2009-12-05 13:24:06 -08:00
Ajay Dudani 57c181c2ed Merge commit 'refs/changes/61/14061/6' of git://git-android.quicinc.com/kernel/lk into clean_tip 2009-12-05 13:23:22 -08:00
Ajay Dudani 5a1e330b58 [msm] Remove proc comm calls to enable usb clocks
On 7x30 targets, usb clocks can be enabled locally by apps processor.
For 7x27 & 8x50 targets, usb clocks are already initialized by modem
processor, so apps need not proc comm to modem to enable these clocks.

Having a proc comm forces apps to wait for modem to initialize, which
delays apps side boot up.

Boot up time on qsd8k with proc comm: 24 seconds
Boot up time on qsd8k without proc comm: 21 seconds
2009-12-05 13:19:17 -08:00
Chandan Uddaraju 885e4db2cd [target]: Add code to get LINUX_MACHTYPE by calling a function for all targets
Add code to read the hardware platform and return the corresponding
LINUX_MACHTYPE for msm7630_surf target.
2009-12-04 21:24:39 -08:00
Ajay Dudani 86e1b4207c [msm] Update density values for supported 16 bit nand devices
Update density values for 16 bit nand devices, else seeing an ASSERT
in density, page size, number of blocks related math.  nand driver
already has all other changes to work with 16 bit 2K page nand device.
2009-12-04 20:57:37 -08:00
Harry Yang 953ff70651 [qsd8k] Add code to support Scorpion warm boot in lk bootloader
Before going into power collapse, the kernel does not change the reset
vector, so execution resumes at bootloader.  Add check in bootloader
to detect warm boot v/s cold boot and if warm boot is detected then
jump to kernel after doing cpu early initializations.
2009-12-04 10:23:40 -08:00
Ajay Dudani 1a23bb249d [msm7x30] Fix copyright markings 2009-12-03 13:56:24 -08:00
QuIC Gerrit Code Review 209224474e Merge change I5fa471ae
* changes:
  [msm7630]: Add code to support qwerty keypad in lk bootloader
2009-12-02 21:31:14 -08:00
QuIC Gerrit Code Review 3351e596b7 Merge change I57746750
* changes:
  [msm7627_surf]: Add code to disable display initialization during bootup.
2009-12-02 21:30:59 -08:00
Chandan Uddaraju 5fa471ae07 [msm7630]: Add code to support qwerty keypad in lk bootloader 2009-12-02 17:31:34 -08:00
Ajay Dudani fa746afad2 [target] Fix CAF copyrights 2009-12-02 13:51:09 -08:00
Ajay Dudani 232ce81283 [msm7630] Add support for msm7630 basic bootup
Add support for basic bootup for msm7630:
 * Adding msm7630 as a new platform and surf as a new target
 * GP & DG timer base address changes
 * NAND, data mover, proc comm, usb base address changes
 * Fix aboot to work with 4K page nand instead of hardcoding 2K page
 * Also fix cpu init for qsd8k
2009-12-02 09:54:42 -08:00
Chandan Uddaraju 805d3cc9d2 [msm7627_surf]: Add code to disable display initialization during bootup. 2009-12-01 16:21:56 -08:00
Ajay Dudani ae80c6e986 [qsd8k] Update cpu initialization from 'legacy' bootloader 2009-11-28 14:15:03 -08:00
Ajay Dudani 60b5b5d39e [qsd8k] Bump up Scorpion CPU speed to 768MHz 2009-11-25 15:48:42 -08:00
Ajay Dudani b1b7d1039c [msm] Update copyright notice for acpuclock.c
Update copyright notice.  The file was derived from
bootable/bootlaoder/legacy's clock.c which originally had Google
copyright.  Restoring the same.
2009-11-25 14:47:20 -08:00
Ajay Dudani 32edd47edf [lk] Update copyrights for added & modified files 2009-11-25 14:43:14 -08:00
QuIC Gerrit Code Review 5fc49d7f74 Merge change I0ec234c7
* changes:
  [msm_shared]: Add code to modify the density value of one of the nand device.
2009-11-25 09:39:46 -08:00
QuIC Gerrit Code Review 1fe987c8c2 Merge change I96f581d9
* changes:
  [target]: Add code to disable display initialization for msm7627_ffa.
2009-11-25 09:39:35 -08:00
QuIC Gerrit Code Review fe75cdab0a Merge change I4e5554d5
* changes:
  [msm7627_ffa]: Add code to change the key mapping for msm7627_ffa.
2009-11-25 09:39:23 -08:00
QuIC Gerrit Code Review 4e28a3978a Merge change I60a888ad
* changes:
  [qsd8250_ffa]: Add code to change the FFA key mapping.
2009-11-24 23:01:55 -08:00
Chandan Uddaraju 96f581d912 [target]: Add code to disable display initialization for msm7627_ffa. 2009-11-24 22:38:40 -08:00
Chandan Uddaraju 0ec234c7e4 [msm_shared]: Add code to modify the density value of one of the nand device. 2009-11-24 22:34:50 -08:00
Chandan Uddaraju 4e5554d545 [msm7627_ffa]: Add code to change the key mapping for msm7627_ffa. 2009-11-24 21:38:46 -08:00
Chandan Uddaraju 7a5f4fa203 [target/init.c]: Add code to change the userdata length to 76MB
Add code to change the userdata length to 76MB for msm7627_surf,
msm7627_ffa, msm7630_surf, qsd8250_surf and qsd8250_ffa targets.
2009-11-24 19:12:31 -08:00
Chandan Uddaraju 60a888ad7c [qsd8250_ffa]: Add code to change the FFA key mapping. 2009-11-24 15:25:36 -08:00
Chandan Uddaraju c6860e1e8a [aboot]: Enable ATAG_MEM info for all the targets.
Add ATAG_MEM data for all the targets.
Modify the LINUX_MACHTYPES for qsd8250_ffa and msm7627_ffa targets.

Signed-off-by: Chandan Uddaraju <chandanu@quicinc.com>
2009-11-22 11:41:34 -08:00
Ajay Dudani a66de4f52c bootloader: Clone msm7627_ffa and qsd8250_ffa target from surf 2009-11-22 08:57:39 -08:00
QuIC Gerrit Code Review be845fe67f Merge change Ia9b07bba
* changes:
  [lk/makefile]: Add code to generate appsboot.mbn file for 7627_surf, 7630_surf and 8250_surf targets
2009-11-21 18:12:20 -08:00
QuIC Gerrit Code Review b163854bce Merge change If72ce81d
* changes:
  [lk/include]: Add limits.h to make LK compatible to arm-eabi-gcc-4.4.0.
2009-11-21 18:12:04 -08:00
Chandan Uddaraju a9b07bbae1 [lk/makefile]: Add code to generate appsboot.mbn file for 7627_surf, 7630_surf and 8250_surf targets
Add code to generate appsboot.mbn for 3 targets. Add make file to support
integration of lk to eclair tree.
2009-11-21 12:22:02 -08:00
Chandan Uddaraju f72ce81dd7 [lk/include]: Add limits.h to make LK compatible to arm-eabi-gcc-4.4.0. 2009-11-21 10:47:29 -08:00
Shashank Mittal d0c836d5ba NAND: Add code to mark bad blocks on nand and onenand
Add support in bootloader to mark blocks of nand/onenand devices as bad
blocks in case of page write failure.
2009-11-20 10:31:18 -08:00
Shashank Mittal dcc2e35011 NAND: Add support for NAND devices with 4k page size
Add support to read page, write page and test bad block for nand devices
with 4k page size.
2009-11-20 09:43:46 -08:00
Shashank Mittal ad3d05cc12 NAND: Skip erase, read and write operations on bad blocks
Change to check for bad block before reading, writing or erasing any
page from NAND and ONENAND
2009-11-20 09:42:31 -08:00
Shashank Mittal c20b5a100d NAND: Add support for ONENAND and setup NAND controller CFGO
Add support for ONENAND in lk. Also setup NAND controller CFG0 before
reading device id. We are not guranteed to have CFG0 setup correctly on
bootup.  Set up CFG0 register correctly when reading flash device id.
2009-11-20 09:40:19 -08:00
Shashank Mittal 83d16d0e7a NAND: Add support for 16-bit NAND
Add support for 16-bit NAND in lk
2009-11-20 09:39:19 -08:00
Chandan Uddaraju da91983628 [aboot/surf7k/surf8k] pass kernel addresses to aboot from the target with defines.
Signed-off-by: Chandan Uddaraju <chandanu@quicinc.com>
2009-11-20 00:41:59 -08:00
Chandan Uddaraju cdde2bdfa7 [msm7k/qsd8k]: Disable UART clock initialization
Signed-off-by: Chandan Uddaraju <chandanu@quicinc.com>
2009-11-19 17:33:19 -08:00
QuIC Gerrit Code Review a70008c7d8 Merge change I48a2f55e
* changes:
  [msm7k]: Add code to change the shared memory base address.
2009-11-19 17:28:17 -08:00
QuIC Gerrit Code Review a80af9e4a4 Merge change Ic53a1a1e
* changes:
  [arm][aboot]: Add code to change the default tool chain and the usb device product id.
2009-11-19 17:28:03 -08:00
QuIC Gerrit Code Review ece5e6042a Merge change Ifcc15f55
* changes:
  [msm7k]: Add code to bump up the clock frequency for 7k targets
2009-11-19 17:24:38 -08:00
Chandan Uddaraju 8adde5a77b [project/target]: Add 3 new projects and the corresponding make files.
Add msm7627_surf, msm7630_surf and qsd8250_surf projects and their corresponding
target files.

Signed-off-by: Chandan Uddaraju <chandanu@quicinc.com>
2009-11-19 13:33:57 -08:00
Chandan Uddaraju 48a2f55e03 [msm7k]: Add code to change the shared memory base address.
Signed-off-by: Chandan Uddaraju <chandanu@quicinc.com>
2009-11-18 15:35:46 -08:00
Chandan Uddaraju c53a1a1ec4 [arm][aboot]: Add code to change the default tool chain and the usb device product id. 2009-11-18 14:53:40 -08:00
Chandan Uddaraju fcc15f55bc [msm7k]: Add code to bump up the clock frequency for 7k targets 2009-11-17 21:02:46 -08:00
Brian Swetland 2defe16142 aboot: handle new base address (0x20000000) for qsd8k
Signed-off-by: Brian Swetland <swetland@google.com>
2009-08-18 14:35:59 -07:00
Brian Swetland ac0a9260d0 msm: currently qsd8k has the dsp image below the kernel image 2009-03-18 15:36:39 -07:00
Brian Swetland 06165207bd msm: qsd8k has the shared memory region at a different address 2009-03-18 15:36:35 -07:00
Dima Zavin 5582c7d752 [msm] nand: Add a verify-after-write option.
Signed-off-by: Dima Zavin <dima@android.com>
2009-03-18 10:50:53 -07:00
Dima Zavin 1cf2363925 [surf7k/surf8k] fix flash partition table init.
Old code would try to write past the end of flash.

Signed-off-by: Dima Zavin <dima@android.com>
2009-03-18 10:50:53 -07:00
Dima Zavin ca337f5e37 [msm] nand: Add implementation for getting the flash layout.
Signed-off-by: Dima Zavin <dima@android.com>
2009-03-18 10:50:53 -07:00
Dima Zavin fbde0acbb6 [dev] flash: Add interface to obtain flash layout info
Signed-off-by: Dima Zavin <dima@android.com>
2009-03-18 10:50:53 -07:00
Dima Zavin e5f6435321 [dev] flash: Split up flash_init and set_ptable into separate functions.
Update the users of this function.

Signed-off-by: Dima Zavin <dima@android.com>
2009-03-18 10:50:53 -07:00
Dima Zavin 3862693d19 [scripts] trace32: make switching between 7k and 8k easier.
Also turn off pabort/dabort.
2009-03-18 10:50:53 -07:00
Dima Zavin 42168f2e97 [aboot] pass partition table through atags 2009-02-05 16:01:49 -08:00
Brian Swetland ddf61a2bb3 [msm] factor out debug code into shared area, make configurable
The defines WITH_DEBUG_DCC, WITH_DEBUG_UART, and WITH_DEBUG_FBCON
are used to determine where dputc output goes.  Duplicated code
merged to msm_shared.  Configuration added to project files.
2009-01-29 20:54:42 -08:00
Brian Swetland b3d66d9e85 [qsd8k] remove unused variables and some chatter in lcdc init 2009-01-29 20:42:39 -08:00
Brian Swetland 60ce24cc41 [msm7k] fix warning in gpio.c 2009-01-29 20:39:47 -08:00
Dima Zavin f9faf3a284 [aboot/surf7k/surf8k] pass machtype to aboot from the target with a define 2009-01-29 17:37:22 -08:00
Dima Zavin 6e274c2d38 [msm7k] enable fbcon output for debug messages 2009-01-29 17:36:57 -08:00
Dima Zavin 36785e3e4a [msm7k] mddi support for msm7k and surf-msm7k wvga panel. 2009-01-29 17:36:37 -08:00
Dima Zavin 25ed99486b [dev] fbcon: flush the display after newline/scroll.
Needed if the display requires the data to be manually redrawn after
screen updates.
2009-01-29 17:35:33 -08:00
Dima Zavin d085013f6c [msm7k] add gpio keypad config and flash init 2009-01-29 17:35:17 -08:00
Dima Zavin b42836029f [aboot] unless cancelled with 'back' key, default to booting from flash 2009-01-29 17:35:05 -08:00
Dima Zavin d6455cda90 [dev][gpio_keypad] make the init function wait for one full scan 2009-01-29 17:34:51 -08:00
Dima Zavin 214cc64027 [aboot] added fastboot commands for flash (erase, flash, continue) 2009-01-29 17:34:33 -08:00
Dima Zavin 9c6992d93a [surf-qsd8k] initialize flash 2009-01-29 17:34:28 -08:00
Dima Zavin 9caac25836 [msm] parse qcom partition table info from SMEM 2009-01-29 17:34:18 -08:00
Dima Zavin a404bce68e [msm] support reading/parsing SMEM allocations info table. 2009-01-29 17:34:05 -08:00
Dima Zavin 03cf431de7 [msm] nand flash driver 2009-01-29 17:33:50 -08:00
Dima Zavin e12b4119eb [dev] flash: add flash ops definitions. 2009-01-29 17:33:42 -08:00
Dima Zavin 2b8429d895 [lib] ptable: add basic partition table management. 2009-01-29 17:33:35 -08:00
Dima Zavin ebec43f7b8 [scripts] default trace32 script to using aboot-surf8k project binaries 2009-01-29 17:31:04 -08:00
Dima Zavin 42f13d3822 [dev] gpio_keypad: get rid of compiler warnings 2009-01-29 17:30:37 -08:00
Brian Swetland bfeab36c73 [msm][uart] do not try to read/write uart before it is initialized 2009-01-29 17:28:40 -08:00
Brian Swetland 850454462d [aboot] leave icache disabled before starting linux
This is apparently causing issues on some targets.
2009-01-29 17:26:36 -08:00
Brian Swetland f4acf736b6 [msm7k] initialize uart3 2009-01-29 17:25:44 -08:00
Brian Swetland 31016c4b0a [qsd8k] clean up dcc/uart debug options 2009-01-29 17:25:16 -08:00
Brian Swetland a8ec56d032 [qsd8k] initialize uart3 2009-01-29 17:25:02 -08:00
Brian Swetland 89f67ec8e4 [qsd8k] remove workaround for ES1 chips
Signed-off-by: Brian Swetland <swetland@google.com>
2009-01-29 17:23:08 -08:00
Brian Swetland a5e9095def [scripts] trace32 debug scripts for lk on 7k/8k 2009-01-26 02:15:35 -08:00
Dima Zavin f8cefec6e6 [qsd8k] add support for the gpio keypad. 2009-01-25 17:39:04 -08:00
Dima Zavin 0f88be2b9b [dev][keys] Initial support for gpio keypads. 2009-01-25 17:39:00 -08:00
Dima Zavin 86aafc263e [qsd8k] gpio device support 2009-01-25 17:38:56 -08:00
Dima Zavin 443afca29b [dev] add primitive keys state management (keys device) 2009-01-25 17:38:52 -08:00
Dima Zavin afa6839a16 generic: add ops/defines to work with multi-word bitmaps. 2009-01-25 17:38:48 -08:00
Brian Swetland d153278b80 [project] projects for aboot on surf 7k and surf 8k 2009-01-25 17:38:44 -08:00
Brian Swetland 9c4c075b7f [app][aboot] Android Bootloader 2009-01-25 17:38:39 -08:00
Brian Swetland d0da856b00 [msm] enable uart init code, include workaround for qsd8k clock issue 2009-01-25 17:38:33 -08:00
Dima Zavin e35e75b824 [qsd8k] basic support for fbcon. 2009-01-25 17:38:29 -08:00
Dima Zavin d5b0b6a345 [dev] add framebuffer console device. 2009-01-25 17:38:24 -08:00
Brian Swetland 0d7b1b887f [msm] timer: provide uninit function, sync support on qsd8k 2009-01-25 17:38:19 -08:00
Brian Swetland 3f924612e7 [msm7k] add missing irq numbers 2009-01-25 17:38:14 -08:00
Brian Swetland 3e7e21ac32 [msm] hsusb udc driver for the chipidea usb client peripheral 2009-01-25 17:38:09 -08:00
Brian Swetland 9a2cd26f48 [dev][udc] simple interface for usb device controllers 2009-01-25 17:38:05 -08:00
Brian Swetland a07d2fad5b [docs] provide rules for correct usage of events, mutexes, and timers 2009-01-25 17:37:44 -08:00
Brian Swetland f1e5afdb3c [lk] allow "make projectname" 2009-01-24 22:09:30 -08:00
Travis Geiselbrecht 577036f27f get rid of project as a container of code, flatten it one level 2009-01-24 21:45:36 -08:00
Travis Geiselbrecht c6760010af remove project_init() 2009-01-24 21:45:36 -08:00
Travis Geiselbrecht 668383c506 [app] change the app api to have an init and entry point 2009-01-24 21:45:36 -08:00
Travis Geiselbrecht 3f14b667d3 [app] convert the existing apps to the app modules, add new shell app to
contain the console
2009-01-24 21:21:54 -08:00
Travis Geiselbrecht 6837223d02 [app] add the app module init system 2009-01-24 21:21:08 -08:00
Travis Geiselbrecht ef67d2b29d remove nettests 2009-01-24 20:17:49 -08:00
Travis Geiselbrecht 5bcbd9d68e move the stray .mk files from the root dir into a make/ subdir 2009-01-24 20:15:32 -08:00
Travis Geiselbrecht 39dededa26 move all of the references to app/console to lib/console 2009-01-24 20:12:57 -08:00
Travis Geiselbrecht 0166fb2d09 move app/console to lib/console 2009-01-24 20:12:52 -08:00
Travis Geiselbrecht bb777a15de [kernel] fix bug in event_signal with AUTOUNSIGNAL flag
Would not mark the event as unsignalled before potentially
releasing any waiting threads, which would let them fall through
event_wait until the signalling thread was run again.
2009-01-20 00:33:22 -08:00
Travis Geiselbrecht 09eeebda43 [arm] only restore the relevant parts of cpsr in arm debug code 2009-01-20 00:33:07 -08:00
Travis Geiselbrecht 3db8380506 [arm] properly restore spsr on exception exit 2009-01-16 20:10:29 -08:00
Brian Swetland c82fda987d [msm] fix dumb bugs in uart.c and debug.c
This gets the serial console working, provided the UART is initialized
when lk starts.  UART initialization still needs some love.
2009-01-02 01:54:39 -08:00
Brian Swetland 977224fca1 [arm][msm] hsusb_clock_init() for configuring USB clocks 2009-01-02 01:33:04 -08:00
Brian Swetland d5b7ac1670 [arm][msm7k] gpio device support 2009-01-02 01:32:12 -08:00
Brian Swetland 12981aadf8 [dev] minimal generic gpio device api 2009-01-02 01:31:43 -08:00
Brian Swetland dfdb461ac5 [msm] initial qsd8k support (tested on qsd8250 surf) 2009-01-01 11:47:09 -08:00
Brian Swetland 9a47753af7 [msm] proc_comm initial support
basic support for the proc_comm shared memory ipc interface,
needed to make requests of the baseband cpu for clocks, power,
etc.
2009-01-01 11:47:04 -08:00
Brian Swetland 5240291080 [arm] force 4 byte alignment of data segments in the linkscript 2009-01-01 11:46:59 -08:00
Brian Swetland af7dab48bb arm: arch_idle: don't use swfi on msm7k
It's not safe to enter swfi without reducing clock, etc.  Disable this
path for the time being to avoid side-effects.
2009-01-01 11:46:51 -08:00
Brian Swetland eceda412f8 arm: mmu: deal with peripheral mapping on msm7k
Peripherals must be accessed as DEVICE NON-SHARED.
2009-01-01 11:46:26 -08:00
Travis Geiselbrecht 1c87cc2f79 [target][surf] add surf-test to the buildall script 2009-01-01 05:34:09 -08:00
Brian Swetland 2500aa11a2 arm: add msm7k platform, common msm drivers, and surf-msm7k target 2009-01-01 05:33:26 -08:00
Travis Geiselbrecht 345adb5b1a [usb] merge in some changes from another code base to make the usb
string manipulation a little simpler
2009-01-01 05:27:06 -08:00
Travis Geiselbrecht 0e7131563d [usb][beagle] beagleboard test usb setup 2009-01-01 03:47:07 -08:00
Travis Geiselbrecht 7689f35834 [usb][omap3] working omap3 usb driver 2009-01-01 03:47:07 -08:00
Travis Geiselbrecht 89fcb14409 [usb] first stab at a usb device stack 2009-01-01 03:47:07 -08:00
Travis Geiselbrecht 47e7539eae get usbc building again after debug changes 2009-01-01 03:47:07 -08:00
Travis Geiselbrecht 2c691e84a4 work in progress of usb controller and usb stack for omap3 2009-01-01 03:47:07 -08:00
Travis Geiselbrecht 6ec9c27dd5 [omap3] start of twl4030 driver 2009-01-01 03:46:37 -08:00
Travis Geiselbrecht bea5a4aee3 [omap3] i2c driver 2009-01-01 03:46:37 -08:00
Brian Swetland a8cf2b81b5 arm: provide __cpu_early_init hook
Only call if WITH_CPU_EARLY_INIT is set.
Move the OMAP3 specific init to use this mechanism.
2009-01-01 03:41:54 -08:00
Brian Swetland 7057769716 arm: the dcc code works for V6 or V7, not just 1136 2009-01-01 03:41:05 -08:00
Brian Swetland 9c19412187 provide linux-style readl()/writel() in reg.h 2009-01-01 03:41:03 -08:00
Brian Swetland 7d7380c460 [ARM] fix missing newline at eof in dcc.S 2009-01-01 03:40:57 -08:00
travis geiselbrecht 858b1ad125 [kernel] properly initialize the default thread context very early to avoid crash on pixies 2008-12-30 23:50:50 -08:00
travis geiselbrecht c60a2e65c1 [kernel] simple thread local storage 2008-12-30 23:42:05 -08:00
Travis Geiselbrecht 6c5fa8a819 [libc] move most vsprintfs to vsnprintfs 2008-12-30 23:40:36 -08:00
travis geiselbrecht 9d564f1bd6 [libc] add n versions of sprintf and vprintf 2008-12-30 23:40:25 -08:00
Brian Swetland d647d7616e add *~ to .gitignore -- remove emacs droppings 2008-12-07 22:58:22 -08:00
Travis Geiselbrecht b57cdae79d update a printf in the kernel init to match reality 2008-10-10 03:19:52 -07:00
travis geiselbrecht d98cea14c8 [kernel] fix the AUTOUNSIGNAL path on kernel events to wait until a thread waits on the event
in the case of it being signalled when there is no waiters pending.
2008-09-18 09:07:24 -07:00
Travis Geiselbrecht eb9460542e [IO] rework dprintf to take a debug level, defined in DEBUGLEVEL
printf at the moment just calls dprintf, but soon will become
a seperate I/O queue.
2008-09-13 15:21:57 -07:00
Travis Geiselbrecht 8d529ef70a [ARM] update atomic ops to use the ldr/strex instructions on armv6+ 2008-09-13 15:13:21 -07:00
Travis Geiselbrecht b26a2d02ab update the beagle test script to put in the right directory 2008-09-13 15:12:46 -07:00
Travis Geiselbrecht f1cdea3729 [INT] fix the mask/unmask interrupt api to not take oldstate argument 2008-09-13 14:13:54 -07:00
Brian Swetland 0e6cd9224b arm: mmu: remove duplicate definitions for MMU flags
The arm/mmu.h header already has these flags.
2008-09-07 02:27:02 -07:00
Brian Swetland e1d0b57f77 arm: add dcc "uart" functionality 2008-09-07 02:26:06 -07:00
Brian Swetland 544bf4ecde add arm1136j-s as a valid ARM_CPU option 2008-09-07 01:13:21 -07:00
Travis Geiselbrecht 97481e67a1 [EABI] test for eabi compatibility a little bit better than before 2008-09-05 04:50:56 -07:00
Travis Geiselbrecht 82f7420325 [EABI] add support for EABI/linux toolchains
pretty much a hack right now, more or less testing for
arm-none-linux-eabi- in the toolchain prefix and adding some routines
that have to be implemented.
2008-09-05 04:35:45 -07:00
Travis Geiselbrecht dfd2eb62e9 [EABI] only typedef size_t if it hasn't been defined by the toolchain 2008-09-05 04:26:25 -07:00
Travis Geiselbrecht 887061fc2e synchronize with external depot
-add relocation code to initial asm setup
-print the top of the stack on a crash
-turn off debug spew when threads exit
-make sure the critical section routines are fully inlined
-remove warning in dpc code
2008-09-05 04:18:30 -07:00
Travis Geiselbrecht f54ab82112 flatten the make system a little bit by providing only modules as a
compilation unit.

to add a module as a dependency of another, just add to the MODULE make
variable, instead of APPS/LIBS/DEVS
2008-09-05 04:18:30 -07:00
Travis Geiselbrecht 573f8608e4 add local.mk to .gitignore 2008-09-05 03:45:28 -07:00
Travis Geiselbrecht c3226113a1 [omap3] make the L2 init actually work 2008-09-02 02:47:40 -07:00
Travis Geiselbrecht bcc0773cd7 [omap3] add the appropriate little smi blurb you have to do to enable
the L2
2008-09-02 00:42:34 -07:00
Travis Geiselbrecht 5bfddfb66a remove lwip, never really worked anyway 2008-09-01 02:56:25 -07:00
Travis Geiselbrecht 1d0df69964 initial commit of lk (little kernel) project 2008-09-01 02:26:09 -07:00
1813 changed files with 531636 additions and 1 deletions

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
build-*
*.swp
*~
tags
TAGS
local.mk
target/*/tools/mkheader
# cscope files
cscope.*
ncscope.*
# temp work area
tmp
+74
View File
@@ -0,0 +1,74 @@
#Android makefile to build lk bootloader as a part of Android Build
TARGET_BOOTLOADER := $(PRODUCT_OUT)/appsboot.mbn
BOOTLOADER_OUT := $(TOP)/$(TARGET_OUT_INTERMEDIATES)/BOOTLOADER_OBJ
ifeq ($(call is-android-codename,HONEYCOMB),true)
CROSS_TOOL := ../../../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
else
CROSS_TOOL := ../../../prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
endif
# Remove bootloader binary to trigger recompile when source changes
appsbootldr_clean:
$(hide) rm -f $(TARGET_BOOTLOADER)
$(hide) rm -rf $(BOOTLOADER_OUT)
$(BOOTLOADER_OUT):
mkdir -p $(BOOTLOADER_OUT)
TARGET_EMMC := 0
ifeq ($(TARGET_USERIMAGES_USE_EXT2),true)
TARGET_EMMC := 1
endif
ifeq ($(TARGET_USERIMAGES_USE_EXT3),true)
TARGET_EMMC := 1
endif
ifeq ($(TARGET_USERIMAGES_USE_EXT4),true)
TARGET_EMMC := 1
endif
ifeq ($(TARGET_BOOTIMG_SIGNED),true)
SIGNED_KERNEL := SIGNED_KERNEL=1
else
SIGNED_KERNEL := SIGNED_KERNEL=0
endif
ifeq ($(TARGET_EMMC),1)
TARGET_BOOTLOADER_EMMC := $(PRODUCT_OUT)/EMMCBOOT.MBN
BOOTLOADER_EMMC_OUT := $(TOP)/$(TARGET_OUT_INTERMEDIATES)/BOOTLOADER_EMMC_OBJ
emmc_appsbootldr_clean:
$(hide) rm -f $(TARGET_BOOTLOADER_EMMC)
$(hide) rm -rf $(BOOTLOADER_EMMC_OUT)
$(BOOTLOADER_EMMC_OUT):
mkdir -p $(BOOTLOADER_EMMC_OUT)
$(TARGET_BOOTLOADER): appsbootldr_clean emmc_appsbootldr_clean $(BOOTLOADER_OUT) $(BOOTLOADER_EMMC_OUT)
$(MAKE) -C bootable/bootloader/lk TOOLCHAIN_PREFIX=$(CROSS_TOOL) BOOTLOADER_OUT=../../../$(BOOTLOADER_OUT) $(TARGET_PRODUCT) $(SIGNED_KERNEL)
$(MAKE) -C bootable/bootloader/lk TOOLCHAIN_PREFIX=$(CROSS_TOOL) BOOTLOADER_OUT=../../../$(BOOTLOADER_EMMC_OUT) $(TARGET_PRODUCT) EMMC_BOOT=1 $(SIGNED_KERNEL)
else
$(TARGET_BOOTLOADER): appsbootldr_clean $(BOOTLOADER_OUT)
$(MAKE) -C bootable/bootloader/lk TOOLCHAIN_PREFIX=$(CROSS_TOOL) BOOTLOADER_OUT=../../../$(BOOTLOADER_OUT) $(TARGET_PRODUCT) $(SIGNED_KERNEL)
endif
#build nandwrite as a part of Android Build
TARGET_NANDWRITE := $(PRODUCT_OUT)/obj/nandwrite/build-$(TARGET_PRODUCT)_nandwrite/lk
NANDWRITE_OUT := $(TOP)/$(TARGET_OUT_INTERMEDIATES)/nandwrite
nandwrite_clean:
$(hide) rm -f $(TARGET_NANDWRITE)
$(hide) rm -rf $(NANDWRITE_OUT)
$(NANDWRITE_OUT):
mkdir -p $(NANDWRITE_OUT)
$(TARGET_NANDWRITE): nandwrite_clean $(NANDWRITE_OUT)
@echo $(TARGET_PRODUCT)_nandwrite
$(MAKE) -C bootable/bootloader/lk TOOLCHAIN_PREFIX=$(CROSS_TOOL) BOOTLOADER_OUT=../../../$(NANDWRITE_OUT) $(TARGET_PRODUCT)_nandwrite BUILD_NANDWRITE=1
+22
View File
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2008-2010 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+8
View File
@@ -0,0 +1,8 @@
moboot - Mobile Open Bootloader
TBD
fnd98109mob.ver
+1281
View File
File diff suppressed because it is too large. Load diff
+97
View File
@@ -0,0 +1,97 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _BOOT_IMAGE_H_
#define _BOOT_IMAGE_H_
typedef struct boot_img_hdr boot_img_hdr;
#define BOOT_MAGIC "ANDROID!"
#define BOOT_MAGIC_SIZE 8
#define BOOT_NAME_SIZE 16
#define BOOT_ARGS_SIZE 512
struct boot_img_hdr
{
unsigned char magic[BOOT_MAGIC_SIZE];
unsigned kernel_size; /* size in bytes */
unsigned kernel_addr; /* physical load addr */
unsigned ramdisk_size; /* size in bytes */
unsigned ramdisk_addr; /* physical load addr */
unsigned second_size; /* size in bytes */
unsigned second_addr; /* physical load addr */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
unsigned char cmdline[BOOT_ARGS_SIZE];
unsigned id[8]; /* timestamp / checksum / sha1 / etc */
};
/*
** +-----------------+
** | boot header | 1 page
** +-----------------+
** | kernel | n pages
** +-----------------+
** | ramdisk | m pages
** +-----------------+
** | second stage | o pages
** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
** m = (ramdisk_size + page_size - 1) / page_size
** o = (second_size + page_size - 1) / page_size
**
** 0. all entities are page_size aligned in flash
** 1. kernel and ramdisk are required (size != 0)
** 2. second is optional (second_size == 0 -> no second)
** 3. load each element (kernel, ramdisk, second) at
** the specified physical address (kernel_addr, etc)
** 4. prepare tags at tag_addr. kernel_args[] is
** appended to the kernel commandline in the tags.
** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
** 6. if second_size != 0: jump to second_addr
** else: jump to kernel_addr
*/
boot_img_hdr *mkbootimg(void *kernel, unsigned kernel_size,
void *ramdisk, unsigned ramdisk_size,
void *second, unsigned second_size,
unsigned page_size,
unsigned *bootimg_size);
void bootimg_set_cmdline(boot_img_hdr *hdr, const char *cmdline);
#endif
+45
View File
@@ -0,0 +1,45 @@
/*
* * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEVINFO_H_
#define _DEVINFO_H_
typedef struct device_info device_info;
#define DEVICE_MAGIC "ANDROID-BOOT!"
#define DEVICE_MAGIC_SIZE 13
struct device_info
{
unsigned char magic[DEVICE_MAGIC_SIZE];
bool is_unlocked;
bool is_tampered;
};
#endif
+462
View File
@@ -0,0 +1,462 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <debug.h>
#include <string.h>
#include <stdlib.h>
#include <kernel/thread.h>
#include <kernel/event.h>
#include <dev/udc.h>
#include <target/gpiokeys.h>
#define MAX_RSP_SIZE 64
void boot_linux(void *bootimg, unsigned sz);
/* todo: give lk strtoul and nuke this */
static unsigned hex2unsigned(const char *x)
{
unsigned n = 0;
while(*x) {
switch(*x) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
n = (n << 4) | (*x - '0');
break;
case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f':
n = (n << 4) | (*x - 'a' + 10);
break;
case 'A': case 'B': case 'C':
case 'D': case 'E': case 'F':
n = (n << 4) | (*x - 'A' + 10);
break;
default:
return n;
}
x++;
}
return n;
}
struct fastboot_cmd {
struct fastboot_cmd *next;
const char *prefix;
unsigned prefix_len;
void (*handle)(const char *arg, void *data, unsigned sz);
};
struct fastboot_var {
struct fastboot_var *next;
const char *name;
const char *value;
};
static struct fastboot_cmd *cmdlist;
void fastboot_register(const char *prefix,
void (*handle)(const char *arg, void *data, unsigned sz))
{
struct fastboot_cmd *cmd;
cmd = malloc(sizeof(*cmd));
if (cmd) {
cmd->prefix = prefix;
cmd->prefix_len = strlen(prefix);
cmd->handle = handle;
cmd->next = cmdlist;
cmdlist = cmd;
}
}
static struct fastboot_var *varlist;
void fastboot_publish(const char *name, const char *value)
{
struct fastboot_var *var;
var = malloc(sizeof(*var));
if (var) {
var->name = name;
var->value = value;
var->next = varlist;
varlist = var;
}
}
static event_t usb_online;
static event_t txn_done;
static unsigned char inbuffer[4096];
static unsigned char outbuffer[4096];
static unsigned char cmdbuffer[4096];
static struct udc_endpoint *in, *out;
static struct udc_request *req;
int txn_status;
static void *download_base;
static unsigned download_max;
static unsigned download_size;
#define STATE_OFFLINE 0
#define STATE_COMMAND 1
#define STATE_COMPLETE 2
#define STATE_ERROR 3
static unsigned fastboot_state = STATE_OFFLINE;
static void req_complete(struct udc_request *req, unsigned actual, int status)
{
txn_status = status;
req->length = actual;
event_signal(&txn_done, 0);
}
static int usb_read(void *_buf, unsigned len)
{
int r;
unsigned xfer;
unsigned char *buf = _buf;
int count = 0;
if (fastboot_state == STATE_ERROR)
goto oops;
while (len > 0) {
xfer = (len > 4096) ? 4096 : len;
req->buf = buf;
req->length = xfer;
req->complete = req_complete;
r = udc_request_queue(out, req);
if (r < 0) {
dprintf(INFO, "usb_read() queue failed\n");
goto oops;
}
event_wait(&txn_done);
if (txn_status < 0) {
dprintf(INFO, "usb_read() transaction failed\n");
goto oops;
}
count += req->length;
buf += req->length;
len -= req->length;
/* short transfer? */
if (req->length != xfer) break;
}
return count;
oops:
fastboot_state = STATE_ERROR;
return -1;
}
static int usb_write(void *buf, unsigned len)
{
int r;
if (fastboot_state == STATE_ERROR)
goto oops;
req->buf = buf;
req->length = len;
req->complete = req_complete;
r = udc_request_queue(in, req);
if (r < 0) {
dprintf(INFO, "usb_write() queue failed\n");
goto oops;
}
event_wait(&txn_done);
if (txn_status < 0) {
dprintf(INFO, "usb_write() transaction failed\n");
goto oops;
}
return req->length;
oops:
fastboot_state = STATE_ERROR;
return -1;
}
void fastboot_ack(const char *code, const char *reason)
{
char response[MAX_RSP_SIZE];
if (fastboot_state != STATE_COMMAND)
return;
if (reason == 0)
reason = "";
snprintf(response, MAX_RSP_SIZE, "%s%s", code, reason);
fastboot_state = STATE_COMPLETE;
usb_write(response, strlen(response));
}
void fastboot_info(const char *reason)
{
char response[MAX_RSP_SIZE];
if (fastboot_state != STATE_COMMAND)
return;
if (reason == 0)
return;
snprintf(response, MAX_RSP_SIZE, "INFO%s", reason);
usb_write(response, strlen(response));
}
void fastboot_fail(const char *reason)
{
fastboot_ack("FAIL", reason);
}
void fastboot_okay(const char *info)
{
fastboot_ack("OKAY", info);
}
static void cmd_getvar(const char *arg, void *data, unsigned sz)
{
struct fastboot_var *var;
for (var = varlist; var; var = var->next) {
if (!strcmp(var->name, arg)) {
fastboot_okay(var->value);
return;
}
}
fastboot_okay("");
}
static void cmd_download(const char *arg, void *data, unsigned sz)
{
char response[MAX_RSP_SIZE];
unsigned len = hex2unsigned(arg);
int r;
download_size = 0;
if (len > download_max) {
fastboot_fail("data too large");
return;
}
sprintf(response,"DATA%08x", len);
if (usb_write(response, strlen(response)) < 0)
return;
r = usb_read(download_base, len);
if ((r < 0) || ((unsigned) r != len)) {
fastboot_state = STATE_ERROR;
return;
}
download_size = len;
fastboot_okay("");
}
static void cmd_getkeys(const char *arg, void *data, unsigned sz)
{
int res = gpiokeys_poll(KEY_ALL);
dprintf(ALWAYS, "KEYS: VolUp: %u VolDn: %u Center: %u\n",
(res & KEY_UP) ? 1 : 0,
(res & KEY_DOWN) ? 1 : 0,
(res & KEY_SELECT) ? 1 : 0);
fastboot_state = STATE_COMPLETE;
}
static void fastboot_command_loop(void)
{
struct fastboot_cmd *cmd;
unsigned cmdlen = 0;
unsigned outlen = 0;
unsigned showprompt = 1;
unsigned cmdready = 0;
char prompt[] = "fastboot: ";
int r;
dprintf(INFO,"fastboot: processing commands\n");
again:
cmdbuffer[0] = 0;
cmdlen = 0;
cmdready = 0;
while (fastboot_state != STATE_ERROR) {
if (showprompt == 1) {
showprompt = 0;
r = usb_write(prompt, strlen(prompt));
if (r <0) goto fail;
}
r = usb_read(inbuffer, MAX_RSP_SIZE);
if (r < 0) break;
outlen = 0;
for (unsigned i = 0; i < r; i++) {
if (inbuffer[i] == '\b') {
if (cmdlen > 0) {
outbuffer[outlen++] = '\b';
outbuffer[outlen++] = ' ';
outbuffer[outlen++] = '\b';
cmdlen--;
}
} else if (inbuffer[i] == '\003') {
outbuffer[outlen++] = '^';
outbuffer[outlen++] = 'C';
outbuffer[outlen++] = '\r';
outbuffer[outlen++] = '\n';
cmdlen = 0;
showprompt = 1;
} else if (inbuffer[i] == '\r') {
outbuffer[outlen++] = '\r';
outbuffer[outlen++] = '\n';
cmdbuffer[cmdlen++] = 0;
/*
for (unsigned j = 0; (i + j) < r; j++) {
cmdbuffer[cmdlen++] = inbuffer[i+j];
}
*/
cmdready = 1;
} else {
cmdbuffer[cmdlen++] = inbuffer[i];
outbuffer[outlen++] = inbuffer[i];
}
}
if (outlen > 0) {
outbuffer[outlen] = 0;
r = usb_write(outbuffer, strlen(outbuffer));
if (r <0) break;
}
if (cmdready) showprompt = 1;
if (cmdready && cmdlen > 0) {
dprintf(INFO, "CMD: %s\n", cmdbuffer);
for (cmd = cmdlist; cmd; cmd = cmd->next) {
if (memcmp(cmdbuffer, cmd->prefix, cmd->prefix_len))
continue;
fastboot_state = STATE_COMMAND;
cmd->handle((const char*) cmdbuffer + cmd->prefix_len,
(void*) download_base, download_size);
if (fastboot_state == STATE_COMMAND) {
dprintf(ALWAYS, "unknown failure\n");
// fastboot_fail("unknown reason");
}
goto again;
}
dprintf(ALWAYS, "unknown command\n");
// fastboot_fail("unknown command");
goto again;
}
}
fail:
fastboot_state = STATE_OFFLINE;
dprintf(INFO,"fastboot: oops!\n");
}
static int fastboot_handler(void *arg)
{
for (;;) {
event_wait(&usb_online);
fastboot_command_loop();
}
return 0;
}
static void fastboot_notify(struct udc_gadget *gadget, unsigned event)
{
if (event == UDC_EVENT_ONLINE) {
event_signal(&usb_online, 0);
}
}
static struct udc_endpoint *fastboot_endpoints[2];
static struct udc_gadget fastboot_gadget = {
.notify = fastboot_notify,
.ifc_class = 0xff,
.ifc_subclass = 0x42,
.ifc_protocol = 0x03,
.ifc_endpoints = 2,
.ifc_string = "fastboot",
.ept = fastboot_endpoints,
};
int fastboot_init(void *base, unsigned size)
{
thread_t *thr;
dprintf(INFO, "fastboot_init()\n");
download_base = base;
download_max = size;
event_init(&usb_online, 0, EVENT_FLAG_AUTOUNSIGNAL);
event_init(&txn_done, 0, EVENT_FLAG_AUTOUNSIGNAL);
in = udc_endpoint_alloc(UDC_TYPE_BULK_IN, 512);
if (!in)
goto fail_alloc_in;
out = udc_endpoint_alloc(UDC_TYPE_BULK_OUT, 512);
if (!out)
goto fail_alloc_out;
fastboot_endpoints[0] = in;
fastboot_endpoints[1] = out;
req = udc_request_alloc();
if (!req)
goto fail_alloc_req;
if (udc_register_gadget(&fastboot_gadget))
goto fail_udc_register;
fastboot_register("getkeys:", cmd_getkeys);
fastboot_register("getvar:", cmd_getvar);
fastboot_register("download:", cmd_download);
fastboot_publish("version", "0.5");
thr = thread_create("fastboot", fastboot_handler, 0, DEFAULT_PRIORITY, 4096);
thread_resume(thr);
return 0;
fail_udc_register:
udc_request_free(req);
fail_alloc_req:
udc_endpoint_free(out);
fail_alloc_out:
udc_endpoint_free(in);
fail_alloc_in:
return -1;
}
+51
View File
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __APP_FASTBOOT_H
#define __APP_FASTBOOT_H
int fastboot_init(void *xfer_buffer, unsigned max);
/* register a command handler
* - command handlers will be called if their prefix matches
* - they are expected to call fastboot_okay() or fastboot_fail()
* to indicate success/failure before returning
*/
void fastboot_register(const char *prefix,
void (*handle)(const char *arg, void *data, unsigned size));
/* publish a variable readable by the built-in getvar command */
void fastboot_publish(const char *name, const char *value);
/* only callable from within a command handler */
void fastboot_okay(const char *result);
void fastboot_fail(const char *reason);
void fastboot_info(const char *reason);
#endif
+468
View File
@@ -0,0 +1,468 @@
/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <debug.h>
#include <arch/arm.h>
#include <dev/udc.h>
#include <string.h>
#include <kernel/thread.h>
#include <arch/ops.h>
#include <dev/flash.h>
#include <lib/ptable.h>
#include <dev/keys.h>
#include <platform.h>
#include <partition_parser.h>
#include <mmc.h>
#include "recovery.h"
#include "bootimg.h"
#include "smem.h"
#define BOOT_FLAGS 1
#define UPDATE_STATUS 2
#define ROUND_TO_PAGE(x,y) (((x) + (y)) & (~(y)))
static const int MISC_PAGES = 3; // number of pages to save
static const int MISC_COMMAND_PAGE = 1; // bootloader command is this page
static char buf[4096];
unsigned boot_into_recovery = 0;
extern void reset_device_info();
extern void set_device_root();
int get_recovery_message(struct recovery_message *out)
{
struct ptentry *ptn;
struct ptable *ptable;
unsigned offset = 0;
unsigned pagesize = flash_page_size();
ptable = flash_get_ptable();
if (ptable == NULL) {
dprintf(CRITICAL, "ERROR: Partition table not found\n");
return -1;
}
ptn = ptable_find(ptable, "misc");
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No misc partition found\n");
return -1;
}
offset += (pagesize * MISC_COMMAND_PAGE);
if (flash_read(ptn, offset, (void *) buf, pagesize)) {
dprintf(CRITICAL, "ERROR: Cannot read recovery_header\n");
return -1;
}
memcpy(out, buf, sizeof(*out));
return 0;
}
int set_recovery_message(const struct recovery_message *in)
{
struct ptentry *ptn;
struct ptable *ptable;
unsigned offset = 0;
unsigned pagesize = flash_page_size();
unsigned n = 0;
ptable = flash_get_ptable();
if (ptable == NULL) {
dprintf(CRITICAL, "ERROR: Partition table not found\n");
return -1;
}
ptn = ptable_find(ptable, "misc");
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No misc partition found\n");
return -1;
}
n = pagesize * (MISC_COMMAND_PAGE + 1);
if (flash_read(ptn, offset, (void *) SCRATCH_ADDR, n)) {
dprintf(CRITICAL, "ERROR: Cannot read recovery_header\n");
return -1;
}
offset += (pagesize * MISC_COMMAND_PAGE);
offset += SCRATCH_ADDR;
memcpy((void *) offset, in, sizeof(*in));
if (flash_write(ptn, 0, (void *)SCRATCH_ADDR, n)) {
dprintf(CRITICAL, "ERROR: flash write fail!\n");
return -1;
}
return 0;
}
int read_update_header_for_bootloader(struct update_header *header)
{
struct ptentry *ptn;
struct ptable *ptable;
unsigned offset = 0;
unsigned pagesize = flash_page_size();
ptable = flash_get_ptable();
if (ptable == NULL) {
dprintf(CRITICAL, "ERROR: Partition table not found\n");
return -1;
}
ptn = ptable_find(ptable, "cache");
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No cache partition found\n");
return -1;
}
if (flash_read(ptn, offset, buf, pagesize)) {
dprintf(CRITICAL, "ERROR: Cannot read recovery_header\n");
return -1;
}
memcpy(header, buf, sizeof(*header));
if (strncmp((char *) header->MAGIC, UPDATE_MAGIC, UPDATE_MAGIC_SIZE))
{
return -1;
}
return 0;
}
int update_firmware_image (struct update_header *header, char *name)
{
struct ptentry *ptn;
struct ptable *ptable;
unsigned offset = 0;
unsigned pagesize = flash_page_size();
unsigned pagemask = pagesize -1;
unsigned n = 0;
ptable = flash_get_ptable();
if (ptable == NULL) {
dprintf(CRITICAL, "ERROR: Partition table not found\n");
return -1;
}
ptn = ptable_find(ptable, "cache");
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No cache partition found\n");
return -1;
}
offset += header->image_offset;
n = (header->image_length + pagemask) & (~pagemask);
if (flash_read(ptn, offset, (void *) SCRATCH_ADDR, n)) {
dprintf(CRITICAL, "ERROR: Cannot read radio image\n");
return -1;
}
ptn = ptable_find(ptable, name);
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No %s partition found\n", name);
return -1;
}
if (flash_write(ptn, 0, (void *) SCRATCH_ADDR, n)) {
dprintf(CRITICAL, "ERROR: flash write fail!\n");
return -1;
}
dprintf(INFO, "Partition writen successfully!");
return 0;
}
static int set_ssd_radio_update (char *name)
{
struct ptentry *ptn;
struct ptable *ptable;
unsigned int ssd_cookie[2] = {0x53534443, 0x4F4F4B49};
unsigned pagesize = flash_page_size();
unsigned pagemask = pagesize -1;
unsigned n = 0;
ptable = flash_get_ptable();
if (ptable == NULL) {
dprintf(CRITICAL, "ERROR: Partition table not found\n");
return -1;
}
n = (sizeof(ssd_cookie) + pagemask) & (~pagemask);
ptn = ptable_find(ptable, name);
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No %s partition found\n", name);
return -1;
}
if (flash_write(ptn, 0, ssd_cookie, n)) {
dprintf(CRITICAL, "ERROR: flash write fail!\n");
return -1;
}
dprintf(INFO, "FOTA partition written successfully!");
return 0;
}
int get_boot_info_apps (char type, unsigned int *status)
{
boot_info_for_apps apps_boot_info;
int ret = 0;
ret = smem_read_alloc_entry(SMEM_BOOT_INFO_FOR_APPS,
&apps_boot_info, sizeof(apps_boot_info));
if (ret)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for apps boot info %d\n",ret);
return ret;
}
dprintf(INFO,"boot flag %x update status %x\n",apps_boot_info.boot_flags,
apps_boot_info.status.update_status);
if(type == BOOT_FLAGS)
*status = apps_boot_info.boot_flags;
else if(type == UPDATE_STATUS)
*status = apps_boot_info.status.update_status;
return ret;
}
/* Bootloader / Recovery Flow
*
* On every boot, the bootloader will read the recovery_message
* from flash and check the command field. The bootloader should
* deal with the command field not having a 0 terminator correctly
* (so as to not crash if the block is invalid or corrupt).
*
* The bootloader will have to publish the partition that contains
* the recovery_message to the linux kernel so it can update it.
*
* if command == "boot-recovery" -> boot recovery.img
* else if command == "update-radio" -> update radio image (below)
* else -> boot boot.img (normal boot)
*
* Radio Update Flow
* 1. the bootloader will attempt to load and validate the header
* 2. if the header is invalid, status="invalid-update", goto #8
* 3. display the busy image on-screen
* 4. if the update image is invalid, status="invalid-radio-image", goto #8
* 5. attempt to update the firmware (depending on the command)
* 6. if successful, status="okay", goto #8
* 7. if failed, and the old image can still boot, status="failed-update"
* 8. write the recovery_message, leaving the recovery field
* unchanged, updating status, and setting command to
* "boot-recovery"
* 9. reboot
*
* The bootloader will not modify or erase the cache partition.
* It is recovery's responsibility to clean up the mess afterwards.
*/
int recovery_init (void)
{
struct recovery_message msg;
char partition_name[32];
unsigned valid_command = 0;
int update_status = 0;
// get recovery message
if (get_recovery_message(&msg))
return -1;
if (msg.command[0] != 0 && msg.command[0] != 255) {
dprintf(INFO, "Recovery command: %.*s\n", sizeof(msg.command), msg.command);
}
msg.command[sizeof(msg.command)-1] = '\0'; //Ensure termination
if (!strcmp("boot-recovery",msg.command))
{
if(!strcmp("RADIO",msg.status))
{
/* We're now here due to radio update, so check for update status */
int ret = get_boot_info_apps(UPDATE_STATUS, (unsigned int *) &update_status);
if(!ret && (update_status & 0x01))
{
dprintf(INFO,"radio update success\n");
strcpy(msg.status, "OKAY");
}
else
{
dprintf(INFO,"radio update failed\n");
strcpy(msg.status, "failed-update");
}
strcpy(msg.command, ""); // clearing recovery command
set_recovery_message(&msg); // send recovery message
boot_into_recovery = 1; // Boot in recovery mode
return 0;
}
valid_command = 1;
strcpy(msg.command, ""); // to safe against multiple reboot into recovery
strcpy(msg.status, "OKAY");
set_recovery_message(&msg); // send recovery message
boot_into_recovery = 1; // Boot in recovery mode
return 0;
}
if (!strcmp("update-radio",msg.command)) {
dprintf(INFO,"start radio update\n");
valid_command = 1;
strcpy(partition_name, "FOTA");
}
//Todo: Add support for bootloader update too.
if(!valid_command) {
//We need not to do anything
return 0; // Boot in normal mode
}
#ifdef OLD_FOTA_UPGRADE
if (read_update_header_for_bootloader(&header)) {
strcpy(msg.status, "invalid-update");
goto SEND_RECOVERY_MSG;
}
if (update_firmware_image (&header, partition_name)) {
strcpy(msg.status, "failed-update");
goto SEND_RECOVERY_MSG;
}
#else
if (set_ssd_radio_update(partition_name)) {
/* If writing to FOTA partition fails */
strcpy(msg.command, "");
strcpy(msg.status, "failed-update");
goto SEND_RECOVERY_MSG;
}
else {
/* Setting this to check the radio update status */
strcpy(msg.command, "boot-recovery");
strcpy(msg.status, "RADIO");
goto SEND_RECOVERY_MSG;
}
#endif
strcpy(msg.status, "OKAY");
SEND_RECOVERY_MSG:
set_recovery_message(&msg); // send recovery message
boot_into_recovery = 1; // Boot in recovery mode
reboot_device(0);
return 0;
}
static int emmc_set_recovery_msg(struct recovery_message *out)
{
char *ptn_name = "misc";
unsigned long long ptn = 0;
unsigned int size = ROUND_TO_PAGE(sizeof(*out),511);
unsigned char data[size];
int index = INVALID_PTN;
index = partition_get_index((unsigned char *) ptn_name);
ptn = partition_get_offset(index);
if(ptn == 0) {
dprintf(CRITICAL,"partition %s doesn't exist\n",ptn_name);
return -1;
}
memcpy(data, out, sizeof(*out));
if (mmc_write(ptn , size, (unsigned int*)data)) {
dprintf(CRITICAL,"mmc write failure %s %d\n",ptn_name, sizeof(*out));
return -1;
}
return 0;
}
static int emmc_get_recovery_msg(struct recovery_message *in)
{
char *ptn_name = "misc";
unsigned long long ptn = 0;
unsigned int size = ROUND_TO_PAGE(sizeof(*in),511);
unsigned char data[size];
int index = INVALID_PTN;
index = partition_get_index((unsigned char *) ptn_name);
ptn = partition_get_offset(index);
if(ptn == 0) {
dprintf(CRITICAL,"partition %s doesn't exist\n",ptn_name);
return -1;
}
if (mmc_read(ptn , (unsigned int*)data, size)) {
dprintf(CRITICAL,"mmc read failure %s %d\n",ptn_name, size);
return -1;
}
memcpy(in, data, sizeof(*in));
return 0;
}
int _emmc_recovery_init(void)
{
int update_status = 0;
struct recovery_message msg;
// get recovery message
if(emmc_get_recovery_msg(&msg))
return -1;
if (msg.command[0] != 0 && msg.command[0] != 255) {
dprintf(INFO,"Recovery command: %d %s\n", sizeof(msg.command), msg.command);
}
msg.command[sizeof(msg.command)-1] = '\0'; //Ensure termination
if (!strcmp("update-radio",msg.command))
{
/* We're now here due to radio update, so check for update status */
int ret = get_boot_info_apps(UPDATE_STATUS, (unsigned int *) &update_status);
if(!ret && (update_status & 0x01))
{
dprintf(INFO,"radio update success\n");
strcpy(msg.status, "OKAY");
}
else
{
dprintf(INFO,"radio update failed\n");
strcpy(msg.status, "failed-update");
}
boot_into_recovery = 1; // Boot in recovery mode
}
if (!strcmp("reset-device-info",msg.command))
{
reset_device_info();
}
if (!strcmp("root-detect",msg.command))
{
set_device_root();
}
else
return 0; // do nothing
strcpy(msg.command, ""); // clearing recovery command
emmc_set_recovery_msg(&msg); // send recovery message
return 0;
}
+77
View File
@@ -0,0 +1,77 @@
/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _BOOTLOADER_RECOVERY_H
#define _BOOTLOADER_RECOVERY_H
#define UPDATE_MAGIC "MSM-RADIO-UPDATE"
#define UPDATE_MAGIC_SIZE 16
#define UPDATE_VERSION 0x00010000
/* Recovery Message */
struct recovery_message {
char command[32];
char status[32];
char recovery[1024];
};
struct update_header {
unsigned char MAGIC[UPDATE_MAGIC_SIZE];
unsigned version;
unsigned size;
unsigned image_offset;
unsigned image_length;
unsigned bitmap_width;
unsigned bitmap_height;
unsigned bitmap_bpp;
unsigned busy_bitmap_offset;
unsigned busy_bitmap_length;
unsigned fail_bitmap_offset;
unsigned fail_bitmap_length;
};
int get_recovery_message(struct recovery_message *out);
int set_recovery_message(const struct recovery_message *in);
int read_update_header_for_bootloader(struct update_header *header);
int update_firmware_image (struct update_header *header, char *name);
int recovery_init (void);
extern unsigned boot_into_recovery;
#endif
+9
View File
@@ -0,0 +1,9 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LK_TOP_DIR)/platform/msm_shared/include
OBJS += \
$(LOCAL_DIR)/aboot.o \
$(LOCAL_DIR)/fastboot.o \
$(LOCAL_DIR)/recovery.o
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
typedef struct sparse_header {
uint32_t magic; /* 0xed26ff3a */
uint16_t major_version; /* (0x1) - reject images with higher major versions */
uint16_t minor_version; /* (0x0) - allow images with higer minor versions */
uint16_t file_hdr_sz; /* 28 bytes for first revision of the file format */
uint16_t chunk_hdr_sz; /* 12 bytes for first revision of the file format */
uint32_t blk_sz; /* block size in bytes, must be a multiple of 4 (4096) */
uint32_t total_blks; /* total blocks in the non-sparse output image */
uint32_t total_chunks; /* total chunks in the sparse input image */
uint32_t image_checksum; /* CRC32 checksum of the original data, counting "don't care" */
/* as 0. Standard 802.3 polynomial, use a Public Domain */
/* table implementation */
} sparse_header_t;
#define SPARSE_HEADER_MAGIC 0xed26ff3a
#define CHUNK_TYPE_RAW 0xCAC1
#define CHUNK_TYPE_FILL 0xCAC2
#define CHUNK_TYPE_DONT_CARE 0xCAC3
#define CHUNK_TYPE_CRC 0xCAC4
typedef struct chunk_header {
uint16_t chunk_type; /* 0xCAC1 -> raw; 0xCAC2 -> fill; 0xCAC3 -> don't care */
uint16_t reserved1;
uint32_t chunk_sz; /* in blocks in output image */
uint32_t total_sz; /* in bytes of chunk input file including chunk header and data */
} chunk_header_t;
/* Following a Raw or Fill chunk is data. For a Raw chunk, it's the data in chunk_sz * blk_sz.
* For a Fill chunk, it's 4 bytes of the fill data.
*/
+66
View File
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2009 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <app.h>
#include <kernel/thread.h>
extern const struct app_descriptor __apps_start;
extern const struct app_descriptor __apps_end;
static void start_app(const struct app_descriptor *app);
/* one time setup */
void apps_init(void)
{
const struct app_descriptor *app;
/* call all the init routines */
for (app = &__apps_start; app != &__apps_end; app++) {
if (app->init)
app->init(app);
}
/* start any that want to start on boot */
for (app = &__apps_start; app != &__apps_end; app++) {
if (app->entry && (app->flags & APP_FLAG_DONT_START_ON_BOOT) == 0) {
start_app(app);
}
}
}
static int app_thread_entry(void *arg)
{
const struct app_descriptor *app = (const struct app_descriptor *)arg;
app->entry(app, NULL);
return 0;
}
static void start_app(const struct app_descriptor *app)
{
printf("starting app %s\n", app->name);
thread_resume(thread_create(app->name, &app_thread_entry, (void *)app, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
}
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2011, James Sullins
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+595
View File
@@ -0,0 +1,595 @@
/*
* Copyright (c) 2011, James Sullins
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <app.h>
#include <debug.h>
#include <target/gpiokeys.h>
#include <target/restart.h>
#include <dev/fbcon.h>
#include <dev/display.h>
#include <sys/types.h>
#include <lib/fs.h>
#include <lib/tga.h>
#include <lib/gfxconsole.h>
#include <lib/bootlinux.h>
typedef struct menu_entry
{
char *title;
unsigned type;
char *arg;
char *name;
} menu_entry_t;
unsigned num_menu_entries;
menu_entry_t **entries;
gfx_surface *display_surface;
gfx_surface *splash_surface;
gfx_surface *background_surface;
gfx_surface *tile_surface;
unsigned gfx_trans;
#define BOOT_FS 1
#define BOOT_REBOOT 2
#define BOOT_RECOVER 3
#define BOOT_SHUTDOWN 4
#define BOOT_DFU 5
void boot_splash()
{
unsigned splash_pos_x, splash_pos_y;
if (splash_surface) {
if (splash_surface->width > display_surface->width ||
splash_surface->height > display_surface->height) {
printf("ERROR: Splash image will not fit on display!\n");
return;
}
gfxconsole_clear();
splash_pos_x = (display_surface->width - splash_surface->width) / 2;
splash_pos_y = (display_surface->height - splash_surface->height) / 2;
gfx_surface_blend(display_surface, splash_surface, splash_pos_x,
splash_pos_y);
}
}
void show_background()
{
unsigned pos_x, pos_y;
if (background_surface) {
if (background_surface->width > display_surface->width ||
background_surface->height > display_surface->height) {
printf("ERROR: Background image will not fit on display!\n");
return;
}
gfxconsole_clear();
pos_x = (display_surface->width - background_surface->width) / 2;
pos_y = (display_surface->height - background_surface->height) / 2;
gfx_surface_blend(display_surface, background_surface, pos_x,
pos_y);
}
}
int moboot_menu(unsigned x, unsigned y, menu_entry_t **entries, unsigned init, unsigned total, unsigned timeout)
{
unsigned curpos, i, max, keys, is_pressed, has_timeout, countdown;
time_t tick;
unsigned wiggle_count = 0;
max = total - 1;
curpos = init;
if (timeout) {
has_timeout = 1;
countdown = timeout;
tick = current_time() + 1000;
} else {
has_timeout = 0;
}
while (1) {
for (i = 0; i < total; i++) {
gfxconsole_setpos(x, y + i);
if (i == curpos) {
if (tile_surface) {
gfxconsole_set_colors(0x00000000, 0x000000ff);
printf("%s", entries[i]->title);
gfxconsole_set_colors(0x00000000, 0x00000000);
} else {
gfxconsole_set_colors(0x000000ff, 0x00000000);
printf("%s", entries[i]->title);
gfxconsole_set_colors(0x00000000, 0x000000ff);
}
} else {
if (tile_surface) {
gfxconsole_set_colors(0x00000000, 0x00000000);
printf("%s", entries[i]->title);
} else {
gfxconsole_set_colors(0x00000000, 0x000000ff);
printf("%s", entries[i]->title);
}
}
}
is_pressed = gpiokeys_poll(KEY_ALL);
while (1) {
if (has_timeout) {
if (current_time() > tick) {
tick += 1000;
countdown--;
if (!countdown) {
return curpos;
}
}
gfxconsole_setpos(x, y + total + 1);
if (tile_surface) {
gfxconsole_set_colors(0x00000000, 0x000000ff);
} else {
gfxconsole_set_colors(0x00000000, 0x00ff0000);
}
printf("timeout in %d ", countdown);
if (tile_surface) {
gfxconsole_set_colors(0x00000000, 0x00000000);
} else {
gfxconsole_set_colors(0x00000000, 0x000000ff);
}
}
thread_sleep(10);
keys = gpiokeys_poll(KEY_ALL);
if (has_timeout && keys) {
gfxconsole_setpos(x, y + total + 1);
printf(" ");
has_timeout = 0;
}
if (is_pressed && !keys) {
if (is_pressed & KEY_SELECT) {
return curpos;
}
if (is_pressed & KEY_UP) {
if (curpos == 0) {
curpos = max;
} else {
curpos--;
}
}
if (is_pressed & KEY_DOWN) {
if (curpos == max) {
curpos = 0;
} else {
curpos++;
}
}
break;
} else if (keys) {
is_pressed = keys;
}
}
}
}
void set_menu_entry(char *title, unsigned type, char *arg, char *name)
{
menu_entry_t *entryp = (menu_entry_t *)malloc(sizeof(menu_entry_t));
entryp->title = title;
entryp->type = type;
entryp->arg = arg;
entryp->name = name;
entries[num_menu_entries++] = entryp;
}
void moboot_init(const struct app_descriptor *app)
{
int rv, keys_pressed;
unsigned act;
menu_entry_t *real_entries[32];
char *ptr;
int rc;
char path[256];
char *newpath;
char *newtitle;
char *newname;
unsigned xoff, yoff;
unsigned ramdisk_mounted, ramdisk_start, ramdisk_size;
unsigned i, j;
unsigned default_menu_entry = 0;
unsigned next_menu_entry = 0;
char default_image[256];
char next_image[256];
unsigned default_timeout;
unsigned counted_images;
unsigned use_next;
ssize_t splash_sz;
void *splash_ptr;
ssize_t background_sz;
void *background_ptr;
ssize_t tile_sz;
void *tile_ptr;
char splash_path[256];
unsigned boot_flags;
ssize_t rdmsgsz;
char *rdmsg;
keys_pressed = 0;
display_surface = NULL;
entries = real_entries;
gfx_trans = 0;
gfxconsole_clear();
gfxconsole_setpos(0,0);
ramdisk_mounted = 0;
atags_get_ramdisk(&ramdisk_start, &ramdisk_size);
if (ramdisk_size && ramdisk_start) {
ramdisk_init(ramdisk_start, ramdisk_size);
if (fs_mount("/ramdisk", "/dev/ramdisk")) {
printf("Ramdisk start=%08x size=%08x\n", ramdisk_start, ramdisk_size);
printf("Unable to mount /ramdisk\n");
printf("Press SELECT to continue\n");
gpiokeys_wait_select();
} else {
ramdisk_mounted = 1;
}
}
if (fs_mount("/boot", "/dev/mmcblk0p13")) {
printf("\nUnable to mount /boot, exiting.\n");
while (1) {
thread_sleep(20);
}
}
default_timeout = 5;
if ((rv = fs_load_file("/boot/moboot.timeout", &default_image, 256)) > 0) {
default_image[rv] = 0;
if (default_image[rv - 1] == '\n') default_image[rv - 1] = 0;
default_timeout = atoui(default_image);
}
default_image[0] = 0;
rv = fs_load_file("/boot/moboot.default", &default_image, 256);
if (rv > 0) {
default_image[rv] = 0;
if (default_image[rv - 1] == '\n') default_image[rv - 1] = 0;
}
use_next = 0;
next_image[0] = 0;
rv = fs_load_file("/boot/moboot.next", &next_image, 256);
if (rv > 0) {
next_image[rv] = 0;
if (next_image[rv - 1] == '\n') next_image[rv - 1] = 0;
}
tile_sz = fs_load_file_mem("/boot/moboot.background.tga", &tile_ptr);
background_surface = NULL;
tile_surface = NULL;
if (tile_sz > 0) {
tile_surface = tga_decode(tile_ptr, tile_sz,
GFX_FORMAT_RGB_x888);
struct display_info disp_info;
if (!display_surface) {
display_get_info(&disp_info);
display_surface = gfx_create_surface_from_display(&disp_info);
}
background_surface = gfx_create_surface(NULL,
display_surface->width,
display_surface->height,
display_surface->stride,
display_surface->format);
for (i = 0; i < display_surface->width; i += tile_surface->width) {
for (j = 0; j < display_surface->height;
j += tile_surface->height) {
gfx_surface_blend(background_surface,
tile_surface,
i, j);
}
}
}
num_menu_entries = 0;
i = 0;
counted_images = 0;
while ((rc = fs_dirent("/boot", i, &ptr)) > 0) {
sprintf(path, "/boot/%s", ptr);
if (strncmp("uImage.", ptr, 7) == 0) {
if (strncmp("uImage.moboot", ptr, 13) != 0) {
newtitle = malloc(strlen(ptr) - 7 + 5 + 1);
sprintf(newtitle, "boot %s", ptr + 7);
newpath = malloc(strlen(ptr) + 6 + 1);
sprintf(newpath, "/boot/%s", ptr);
newname = malloc(strlen(ptr) - 7 + 1);
sprintf(newname, "%s", ptr + 7);
if (strcmp(default_image, ptr + 7) == 0) {
default_menu_entry = num_menu_entries;
}
if (strcmp(next_image, ptr + 7) == 0) {
next_menu_entry = num_menu_entries;
use_next = 1;
}
set_menu_entry(newtitle, BOOT_FS, newpath, newname);
counted_images++;
}
}
free(ptr);
i++;
}
if (rc < 0) {
dprintf(SPEW, "/boot dirList ERROR rc = %d\n", rc);
}
i = 0;
while ((rc = fs_dirent("/ramdisk/boot", i, &ptr)) > 0) {
sprintf(path, "/ramdisk/boot/%s", ptr);
if (strncmp("uImage.", ptr, 7) == 0) {
if (strncmp("uImage.moboot", ptr, 13) != 0) {
newtitle = malloc(strlen(ptr) - 7 + 5 + 1);
sprintf(newtitle, "boot %s", ptr + 7);
newpath = malloc(strlen(ptr) + 14 + 1);
sprintf(newpath, "/ramdisk/boot/%s", ptr);
newname = malloc(strlen(ptr) - 7 + 1);
sprintf(newname, "%s", ptr + 7);
if (strcmp(default_image, ptr + 7) == 0) {
default_menu_entry = num_menu_entries;
}
if (strcmp(next_image, ptr + 7) == 0) {
next_menu_entry = num_menu_entries;
use_next = 1;
}
set_menu_entry(newtitle, BOOT_FS, newpath, newname);
counted_images++;
}
}
free(ptr);
i++;
}
if (rc < 0) {
dprintf(SPEW, "/ramdisk/boot dirList ERROR rc = %d\n", rc);
}
if (counted_images == 0) {
set_menu_entry("boot", BOOT_FS, "/boot/uImage-2.6.35-palm-tenderloin", "default");
}
if (gpiokeys_poll(KEY_ALL)) {
keys_pressed = 1;
printf("\nPlease release key(s)...");
while (1) {
thread_sleep(20);
if (!gpiokeys_poll(KEY_ALL)) {
break;
}
}
}
gfx_trans = 0;
if (tile_surface) {
gfx_trans = 1;
}
set_menu_entry("boot webOS Recovery", BOOT_RECOVER, "", "recover");
set_menu_entry("reboot", BOOT_REBOOT, "", "reboot");
// set_menu_entry("DFU", BOOT_DFU, "", "");
set_menu_entry("shutdown", BOOT_SHUTDOWN, "", "shutdown");
xoff = (gfxconsole_getwidth() - 12 ) / 2;
yoff = (gfxconsole_getheight() - (num_menu_entries + 4)) / 2;
#if 0
tgasz = fs_load_file_mem("/boot/moboot.tga", &tgaptr);
tga_surface = NULL;
if (tgasz > 0) {
tga_surface = tga_decode(tgaptr, tgasz, GFX_FORMAT_RGB_x888);
struct display_info disp_info;
if (!display_surface) {
display_get_info(&disp_info);
display_surface = gfx_create_surface_from_display(&disp_info);
}
}
#endif
while (1) {
gfxconsole_clear();
show_background();
if (background_surface) {
gfxconsole_setbackground(background_surface);
}
gfxconsole_settrans(gfx_trans);
gfxconsole_setpos(xoff,yoff);
if (gfx_trans) {
gfxconsole_set_colors(0xffffffff, 0x00000000);
printf("moboot %s", MOBOOT_VERSION);
gfxconsole_setpos(xoff,yoff);
gfxconsole_set_colors(0x00000000, 0x00000000);
} else {
gfxconsole_set_colors(0x00000000, 0xffffffff);
printf("moboot %s", MOBOOT_VERSION);
gfxconsole_set_colors(0x00000000, 0x000000ff);
}
if (!use_next || keys_pressed) {
act = moboot_menu(xoff, yoff + 2, entries, default_menu_entry, num_menu_entries, keys_pressed ? 0 : default_timeout);
} else {
act = next_menu_entry;
use_next = 0;
}
keys_pressed = 1;
gfxconsole_setpos(xoff, yoff + 2 + num_menu_entries + 2);
boot_flags = BOOTLINUX_NOFLAGS;
switch (entries[act]->type) {
case BOOT_RECOVER:
reboot_device(RESTART_REASON_RECOVER);
break;
case BOOT_REBOOT:
reboot_device(RESTART_REASON_REBOOT);
break;
case BOOT_DFU:
reboot_device(RESTART_REASON_DFU);
break;
case BOOT_SHUTDOWN:
reboot_device(RESTART_REASON_SHUTDOWN);
break;
case BOOT_FS:
gfxconsole_clear();
gfxconsole_settrans(gfx_trans);
show_background();
gfxconsole_setpos(0,0);
if (gfx_trans) {
gfxconsole_set_colors(0x00000000, 0x00000000);
} else {
gfxconsole_set_colors(0x00000000, 0x000000ff);
}
printf("Selected: '%s'\n\n", entries[act]->title);
printf("Loading '%s'... ", entries[act]->arg);
if ((rv = fs_load_file(entries[act]->arg,
(void *)SCRATCH_ADDR,
SCRATCH_SIZE * 1024 * 1024)) < 0) {
printf("FAILED\n");
} else {
printf("OK\n");
/* check for verbose boot */
sprintf(splash_path, "/boot/moboot.verbose.%s",
entries[act]->name);
splash_sz = fs_load_file_mem(splash_path, &splash_ptr);
if (splash_sz > 0) {
if (strncmp(splash_ptr, "yes", 3) == 0) {
boot_flags |= BOOTLINUX_VERBOSE;
}
}
/* check for sercon boot */
sprintf(splash_path, "/boot/moboot.sercon.%s",
entries[act]->name);
splash_sz = fs_load_file_mem(splash_path, &splash_ptr);
if (splash_sz > 0) {
if (strncmp(splash_ptr, "yes", 3) == 0) {
boot_flags |= BOOTLINUX_SERCON;
}
}
if (splash_ptr) free(splash_ptr);
/* check for splash image */
sprintf(splash_path, "/boot/moboot.splash.%s.tga",
entries[act]->name);
splash_sz = fs_load_file_mem(splash_path, &splash_ptr);
splash_surface = NULL;
if (splash_sz > 0) {
splash_surface = tga_decode(splash_ptr, splash_sz,
GFX_FORMAT_RGB_x888);
struct display_info disp_info;
if (!display_surface) {
display_get_info(&disp_info);
display_surface = gfx_create_surface_from_display(
&disp_info);
}
}
/* do it to it! */
bootlinux_uimage_mem((void *)SCRATCH_ADDR, rv, boot_splash,
boot_flags);
}
gfxconsole_set_colors(0x00000000, 0x00ff0000);
printf("\n\nBOOT FAILED!\n\nPress SELECT to continue\n");
gfxconsole_set_colors(0x00000000, 0x000000ff);
gpiokeys_wait_select();
break;
}
}
}
#if 0
char *ptr;
int rc;
unsigned i = 0;
char path[256];
filecookie fc;
struct file_stat fstat;
while ((rc = fs_dirent("/boot", i, &ptr)) > 0) {
sprintf(path, "/boot/%s", ptr);
fs_open_file(path, &fc);
fs_stat_file(fc, &fstat);
dprintf(SPEW, "Mode: %06hx ATIME: %08x CTIME: %08x MTIME: %08x NAME: '%s'\n",
fstat.mode, fstat.atime, fstat.ctime, fstat.mtime, ptr);
fs_close_file(fc);
free(ptr);
i++;
}
if (rc < 0) {
dprintf(SPEW, "rc = %d\n", rc);
}
#endif
APP_START(moboot)
.init = moboot_init,
APP_END
+6
View File
@@ -0,0 +1,6 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include
OBJS += \
$(LOCAL_DIR)/moboot.o \
+99
View File
@@ -0,0 +1,99 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _BOOT_IMAGE_H_
#define _BOOT_IMAGE_H_
typedef struct boot_img_hdr boot_img_hdr;
#define BOOT_MAGIC "ANDROID!"
#define BOOT_MAGIC_SIZE 8
#define BOOT_NAME_SIZE 16
#define BOOT_ARGS_SIZE 512
struct boot_img_hdr
{
unsigned char magic[BOOT_MAGIC_SIZE];
unsigned kernel_size; /* size in bytes */
unsigned kernel_addr; /* physical load addr */
unsigned ramdisk_size; /* size in bytes */
unsigned ramdisk_addr; /* physical load addr */
unsigned second_size; /* size in bytes */
unsigned second_addr; /* physical load addr */
unsigned tags_addr; /* physical addr for kernel tags */
unsigned page_size; /* flash page size we assume */
unsigned unused[2]; /* future expansion: should be 0 */
unsigned char name[BOOT_NAME_SIZE]; /* asciiz product name */
unsigned char cmdline[BOOT_ARGS_SIZE];
unsigned id[8]; /* timestamp / checksum / sha1 / etc */
};
/*
** +-----------------+
** | boot header | 1 page
** +-----------------+
** | kernel | n pages
** +-----------------+
** | ramdisk | m pages
** +-----------------+
** | second stage | o pages
** +-----------------+
**
** n = (kernel_size + page_size - 1) / page_size
** m = (ramdisk_size + page_size - 1) / page_size
** o = (second_size + page_size - 1) / page_size
**
** 0. all entities are page_size aligned in flash
** 1. kernel and ramdisk are required (size != 0)
** 2. second is optional (second_size == 0 -> no second)
** 3. load each element (kernel, ramdisk, second) at
** the specified physical address (kernel_addr, etc)
** 4. prepare tags at tag_addr. kernel_args[] is
** appended to the kernel commandline in the tags.
** 5. r0 = 0, r1 = MACHINE_TYPE, r2 = tags_addr
** 6. if second_size != 0: jump to second_addr
** else: jump to kernel_addr
*/
boot_img_hdr *mkbootimg(void *kernel, unsigned kernel_size,
void *ramdisk, unsigned ramdisk_size,
void *second, unsigned second_size,
unsigned page_size,
unsigned *bootimg_size);
void bootimg_set_cmdline(boot_img_hdr *hdr, const char *cmdline);
#endif
+220
View File
@@ -0,0 +1,220 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <app.h>
#include <debug.h>
#include <lib/ptable.h>
#include <malloc.h>
#include <dev/flash.h>
#include <string.h>
#include <jtag.h>
#include <kernel/thread.h>
#include <smem.h>
#include <platform.h>
#include "bootimg.h"
#define FLASH_PAGE_SIZE 2048
#define FLASH_PAGE_BITS 11
unsigned page_size = 0;
unsigned page_mask = 0;
static unsigned load_addr = 0xffffffff;
#define ROUND_TO_PAGE(x,y) (((x) + (y)) & (~(y)))
void acpu_clock_init(void);
int startswith(const char *str, const char *prefix)
{
while(*prefix){
if (*prefix++ != *str++) return 0;
}
return 1;
}
/* XXX */
void verify_flash(struct ptentry *p, void *addr, unsigned len, int extra)
{
uint32_t offset = 0;
void *buf = malloc(FLASH_PAGE_SIZE + extra);
int verify_extra = extra;
if(verify_extra > 4)
verify_extra = 16;
while(len > 0) {
flash_read_ext(p, extra, offset, buf, FLASH_PAGE_SIZE);
if(memcmp(addr, buf, FLASH_PAGE_SIZE + verify_extra)) {
dprintf(CRITICAL, "verify failed at 0x%08x\n", offset);
jtag_fail("verify failed");
return;
}
offset += FLASH_PAGE_SIZE;
addr += FLASH_PAGE_SIZE;
len -= FLASH_PAGE_SIZE;
if(extra) {
addr += extra;
len -= extra;
}
}
dprintf(INFO, "verify done %d extra bytes\n", verify_extra);
jtag_okay("verify done");
}
void handle_flash(const char *name, unsigned addr, unsigned sz)
{
struct ptentry *ptn;
struct ptable *ptable;
void *data = (void *) addr;
unsigned extra = 0;
ptable = flash_get_ptable();
if (ptable == NULL) {
jtag_fail("partition table doesn't exist");
return;
}
ptn = ptable_find(ptable, name);
if (ptn == NULL) {
jtag_fail("unknown partition name");
return;
}
if (!strcmp(ptn->name, "boot") || !strcmp(ptn->name, "recovery")) {
if (memcmp((void *)data, BOOT_MAGIC, BOOT_MAGIC_SIZE)) {
jtag_fail("image is not a boot image");
return;
}
}
if (!strcmp(ptn->name, "system") || !strcmp(ptn->name, "userdata") || !strcmp(ptn->name, "persist"))
extra = ((page_size >> 9) * 16);
else
sz = ROUND_TO_PAGE(sz, page_mask);
data = (void *)target_get_scratch_address();
dprintf(INFO, "writing %d bytes to '%s'\n", sz, ptn->name);
if (flash_write(ptn, extra, data, sz)) {
jtag_fail("flash write failure");
return;
}
dprintf(INFO, "partition '%s' updated\n", ptn->name);
jtag_okay("Done");
enter_critical_section();
platform_uninit_timer();
arch_disable_cache(UCACHE);
arch_disable_mmu();
}
static unsigned char *tmpbuf = 0;
/*XXX*/
void handle_dump(const char *name, unsigned offset)
{
struct ptentry *p;
struct ptable *ptable;
if(tmpbuf == 0) {
tmpbuf = malloc(4096);
}
dprintf(INFO, "dump '%s' partition\n", name);
ptable = flash_get_ptable();
if (ptable == NULL) {
jtag_fail("partition table doesn't exist");
return;
}
p = ptable_find(ptable, name);
if(p == 0) {
jtag_fail("partition not found");
return;
} else {
#if 0
/* XXX reimpl */
if(flash_read_page(p->start * 64, tmpbuf, tmpbuf + 2048)){
jtag_fail("flash_read() failed");
return;
}
#endif
dprintf(INFO, "page %d data:\n", p->start * 64);
hexdump(tmpbuf, 256);
dprintf(INFO, "page %d extra:\n", p->start * 64);
hexdump(tmpbuf, 16);
jtag_okay("done");
enter_critical_section();
platform_uninit_timer();
arch_disable_cache(UCACHE);
arch_disable_mmu();
}
}
void handle_query_load_address(unsigned addr)
{
unsigned *return_addr = (unsigned *)addr;
if (return_addr)
*return_addr = target_get_scratch_address();
jtag_okay("done");
}
void handle_command(const char *cmd, unsigned a0, unsigned a1, unsigned a2)
{
if(startswith(cmd,"flash:")){
handle_flash(cmd + 6, a0, a1);
return;
}
if(startswith(cmd,"dump:")){
handle_dump(cmd + 5, a0);
return;
}
if(startswith(cmd,"loadaddr:")){
handle_query_load_address(a0);
return;
}
jtag_fail("unknown command");
}
void nandwrite_init(void)
{
page_size = flash_page_size();
page_mask = page_size - 1;
jtag_cmd_loop(handle_command);
}
+6
View File
@@ -0,0 +1,6 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
OBJS += \
$(LOCAL_DIR)/nandwrite.o \
+249
View File
@@ -0,0 +1,249 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <app.h>
#include <debug.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <compiler.h>
#include <platform.h>
#include <dev/pci.h>
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
/*
* enumerates pci devices
*/
static void pci_list(void)
{
pci_location_t state;
uint16_t device_id, vendor_id;
uint8_t header_type;
int busses = 0, devices = 0, lines = 0, devfn, ret;
char c;
printf("Scanning...\n");
for (state.bus = 0; state.bus <= pci_get_last_bus(); state.bus++) {
busses++;
for (devfn = 0; devfn < 256; devfn++) {
state.dev_fn = devfn;
ret = pci_read_config_half(&state, PCI_CONFIG_VENDOR_ID, &vendor_id);
if (ret != _PCI_SUCCESSFUL) goto error;
ret = pci_read_config_half(&state, PCI_CONFIG_DEVICE_ID, &device_id);
if (ret != _PCI_SUCCESSFUL) goto error;
ret = pci_read_config_byte(&state, PCI_CONFIG_HEADER_TYPE, &header_type);
if (ret != _PCI_SUCCESSFUL) goto error;
if (vendor_id != 0xffff) {
printf("%02x:%02x vendor_id=%04x device_id=%04x, header_type=%02x\n", state.bus, state.dev_fn,
vendor_id, device_id, header_type);
devices++;
lines++;
}
if (~header_type & PCI_HEADER_TYPE_MULTI_FN) {
// this is not a multi-function device, so advance to the next device
devfn |= 7;
}
if (lines == 23) {
printf("... press any key to continue, q to quit ...");
while(getc(&c) < 0);
printf("\n");
lines = 0;
if (c == 'q' || c == 'Q') goto quit;
}
}
}
printf("... done. Scanned %d busses, %d device/functions\n", busses, devices);
quit:
return;
error:
printf("Error while reading PCI config space: %02x\n", ret);
}
/*
* a somewhat fugly pci config space examine/modify command. this should probably
* be broken up a bit.
*/
static int pci_config(int argc, const cmd_args *argv)
{
pci_location_t loc;
pci_config_t config;
uint32_t offset;
unsigned int i;
int ret;
if (argc < 5) {
return -1;
}
if (!strcmp(argv[2].str, "dump")) {
loc.bus = atoui(argv[3].str);
loc.dev_fn = atoui(argv[4].str);
for (i=0; i < sizeof(pci_config_t); i++) {
ret = pci_read_config_byte(&loc, i, (uint8_t *) &config + i);
if (ret != _PCI_SUCCESSFUL) goto error;
}
printf("Device at %02x:%02x vendor id=%04x device id=%04x\n", loc.bus,
loc.dev_fn, config.vendor_id, config.device_id);
printf("command=%04x status=%04x pi=%02x sub cls=%02x base cls=%02x\n",
config.command, config.status, config.program_interface,
config.sub_class, config.base_class);
for (i=0; i < 6; i+=2) {
printf("bar%d=%08x bar%d=%08x\n", i, config.base_addresses[i],
i+1, config.base_addresses[i+1]);
}
} else if (!strcmp(argv[2].str, "rb") || !strcmp(argv[2].str, "rh") || !strcmp(argv[2].str, "rw")) {
if (argc != 6) {
return -1;
}
loc.bus = atoui(argv[3].str);
loc.dev_fn = atoui(argv[4].str);
offset = atoui(argv[5].str);
switch (argv[2].str[1]) {
case 'b': {
uint8_t value;
ret = pci_read_config_byte(&loc, offset, &value);
if (ret != _PCI_SUCCESSFUL) goto error;
printf("byte at device %02x:%02x config offset %04x: %02x\n", loc.bus, loc.dev_fn, offset, value);
}
break;
case 'h': {
uint16_t value;
ret = pci_read_config_half(&loc, offset, &value);
if (ret != _PCI_SUCCESSFUL) goto error;
printf("half at device %02x:%02x config offset %04x: %04x\n", loc.bus, loc.dev_fn, offset, value);
}
break;
case 'w': {
uint32_t value;
ret = pci_read_config_word(&loc, offset, &value);
if (ret != _PCI_SUCCESSFUL) goto error;
printf("word at device %02x:%02x config offset %04x: %08x\n", loc.bus, loc.dev_fn, offset, value);
}
break;
}
} else if (!strcmp(argv[2].str, "mb") || !strcmp(argv[2].str, "mh") || !strcmp(argv[2].str, "mw")) {
if (argc != 7) {
return -1;
}
loc.bus = atoui(argv[3].str);
loc.dev_fn = atoui(argv[4].str);
offset = atoui(argv[5].str);
switch (argv[2].str[1]) {
case 'b': {
uint8_t value = atoui(argv[6].str);
ret = pci_write_config_byte(&loc, offset, value);
if (ret != _PCI_SUCCESSFUL) goto error;
printf("byte to device %02x:%02x config offset %04x: %02x\n", loc.bus, loc.dev_fn, offset, value);
}
break;
case 'h': {
uint16_t value = atoui(argv[6].str);
ret = pci_write_config_half(&loc, offset, value);
if (ret != _PCI_SUCCESSFUL) goto error;
printf("half to device %02x:%02x config offset %04x: %04x\n", loc.bus, loc.dev_fn, offset, value);
}
break;
case 'w': {
uint32_t value = atoui(argv[6].str);
ret = pci_write_config_word(&loc, offset, value);
if (ret != _PCI_SUCCESSFUL) goto error;
printf("word to device %02x:%02x config offset %04x: %08x\n", loc.bus, loc.dev_fn, offset, value);
}
break;
}
} else {
return -1;
}
return 0;
error:
printf("Error while reading PCI config space: %02x\n", ret);
return -2;
}
static int pci_cmd(int argc, const cmd_args *argv)
{
if (argc < 2) {
printf("pci commands:\n");
usage:
printf("%s list\n", argv[0].str);
printf("%s config dump <bus> <devfn>\n", argv[0].str);
printf("%s config <rb|rh|rw> <bus> <devfn> <offset>\n", argv[0].str);
printf("%s config <mb|mh|mw> <bus> <devfn> <offset> <value>\n", argv[0].str);
goto out;
}
if (!strcmp(argv[1].str, "list")) {
pci_list();
} else if (!strcmp(argv[1].str, "config")) {
if (pci_config(argc, argv)) {
goto usage;
}
} else {
goto usage;
}
out:
return 0;
}
STATIC_COMMAND_START
{ "pci", "pci toolbox", &pci_cmd },
STATIC_COMMAND_END(pcitests);
#endif
APP_START(pcitests)
APP_END
+6
View File
@@ -0,0 +1,6 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
#INCLUDES += -I$(LOCAL_DIR)/include
OBJS += \
$(LOCAL_DIR)/pci_tests.o
+8
View File
@@ -0,0 +1,8 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
MODULES += \
lib/openssl
OBJS += \
$(LOCAL_DIR)/app.o
+7
View File
@@ -0,0 +1,7 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
MODULES += \
lib/console
OBJS += \
$(LOCAL_DIR)/shell.o
+41
View File
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2009 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <app.h>
#include <debug.h>
#include <lib/console.h>
static void shell_init(const struct app_descriptor *app)
{
console_init();
}
static void shell_entry(const struct app_descriptor *app, void *args)
{
console_start();
}
APP_START(shell)
.init = shell_init,
.entry = shell_entry,
APP_END
+169
View File
@@ -0,0 +1,169 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
#include <arch/arm/cores.h>
.text
.align 2
.global mymemcpy
mymemcpy:
// check for zero length copy or the same pointer
cmp r2, #0
cmpne r1, r0
bxeq lr
// save a few registers for use and the return code (input dst)
stmfd sp!, {r0, r4, r5, lr}
// check for forwards overlap (src > dst, distance < len)
subs r3, r0, r1
cmpgt r2, r3
bgt .L_forwardoverlap
// check for a short copy len.
// 20 bytes is enough so that if a 16 byte alignment needs to happen there is at least a
// wordwise copy worth of work to be done.
cmp r2, #(16+4)
blt .L_bytewise
// see if they are similarly aligned on 4 byte boundaries
eor r3, r0, r1
tst r3, #3
bne .L_bytewise // dissimilarly aligned, nothing we can do (for now)
// check for 16 byte alignment on dst.
// this will also catch src being not 4 byte aligned, since it is similarly 4 byte
// aligned with dst at this point.
tst r0, #15
bne .L_not16bytealigned
// check to see if we have at least 32 bytes of data to copy.
// if not, just revert to wordwise copy
cmp r2, #32
blt .L_wordwise
.L_bigcopy:
// copy 32 bytes at a time. src & dst need to be at least 4 byte aligned,
// and we need at least 32 bytes remaining to copy
// save r6-r7 for use in the big copy
stmfd sp!, {r6-r7}
sub r2, r2, #32 // subtract an extra 32 to the len so we can avoid an extra compare
.L_bigcopy_loop:
ldmia r1!, {r4, r5, r6, r7}
stmia r0!, {r4, r5, r6, r7}
ldmia r1!, {r4, r5, r6, r7}
subs r2, r2, #32
stmia r0!, {r4, r5, r6, r7}
bge .L_bigcopy_loop
// restore r6-r7
ldmfd sp!, {r6-r7}
// see if we are done
adds r2, r2, #32
beq .L_done
// less then 4 bytes left?
cmp r2, #4
blt .L_bytewise
.L_wordwise:
// copy 4 bytes at a time.
// src & dst are guaranteed to be word aligned, and at least 4 bytes are left to copy.
subs r2, r2, #4
.L_wordwise_loop:
ldr r3, [r1], #4
subs r2, r2, #4
str r3, [r0], #4
bge .L_wordwise_loop
// correct the remaining len and test for completion
adds r2, r2, #4
beq .L_done
.L_bytewise:
// simple bytewise copy
ldrb r3, [r1], #1
subs r2, r2, #1
strb r3, [r0], #1
bgt .L_bytewise
.L_done:
// load dst for return and restore r4,r5
#if ARM_ARCH_LEVEL >= 5
ldmfd sp!, {r0, r4, r5, pc}
#else
ldmfd sp!, {r0, r4, r5, lr}
bx lr
#endif
.L_not16bytealigned:
// dst is not 16 byte aligned, so we will copy up to 15 bytes to get it aligned.
// src is guaranteed to be similarly word aligned with dst.
// set the condition flags based on the alignment.
lsl r12, r0, #28
rsb r12, r12, #0
msr CPSR_f, r12 // move into NZCV fields in CPSR
// move as many bytes as necessary to get the dst aligned
ldrvsb r3, [r1], #1 // V set
ldrcsh r4, [r1], #2 // C set
ldreq r5, [r1], #4 // Z set
strvsb r3, [r0], #1
strcsh r4, [r0], #2
streq r5, [r0], #4
ldmmiia r1!, {r3-r4} // N set
stmmiia r0!, {r3-r4}
// fix the remaining len
sub r2, r2, r12, lsr #28
// test to see what we should do now
cmp r2, #32
bge .L_bigcopy
b .L_wordwise
// src and dest overlap 'forwards' or dst > src
.L_forwardoverlap:
// do a bytewise reverse copy for now
add r1, r1, r2
add r0, r0, r2
.L_bytewisereverse:
// simple bytewise reverse copy
ldrb r3, [r1], #-1
subs r2, r2, #1
strb r3, [r0], #-1
bgt .L_bytewisereverse
b .L_done
+109
View File
@@ -0,0 +1,109 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
#include <arch/arm/cores.h>
.text
.align 2
/* void *memset(void *s, int c, size_t n); */
.global mymemset
mymemset:
// check for zero length
cmp r2, #0
bxeq lr
// save the original pointer
mov r12, r0
// short memsets aren't worth optimizing
cmp r2, #(32 + 16)
blt .L_bytewise
// fill a 32 bit register with the 8 bit value
and r1, r1, #0xff
orr r1, r1, r1, lsl #8
orr r1, r1, r1, lsl #16
// check for 16 byte alignment
tst r0, #15
bne .L_not16bytealigned
.L_bigset:
// dump some registers to make space for our values
stmfd sp!, { r4-r5 }
// fill a bunch of registers with the set value
mov r3, r1
mov r4, r1
mov r5, r1
// prepare the count register so we can avoid an extra compare
sub r2, r2, #32
// 32 bytes at a time
.L_bigset_loop:
stmia r0!, { r1, r3, r4, r5 }
subs r2, r2, #32
stmia r0!, { r1, r3, r4, r5 }
bge .L_bigset_loop
// restore our dumped registers
ldmfd sp!, { r4-r5 }
// see if we're done
adds r2, r2, #32
beq .L_done
.L_bytewise:
// bytewise memset
subs r2, r2, #1
strb r1, [r0], #1
bgt .L_bytewise
.L_done:
// restore the base pointer as return value
mov r0, r12
bx lr
.L_not16bytealigned:
// dst is not 16 byte aligned, so we will set up to 15 bytes to get it aligned.
// set the condition flags based on the alignment.
lsl r3, r0, #28
rsb r3, r3, #0
msr CPSR_f, r3 // move into NZCV fields in CPSR
// move as many bytes as necessary to get the dst aligned
strvsb r1, [r0], #1 // V set
strcsh r1, [r0], #2 // C set
streq r1, [r0], #4 // Z set
strmi r1, [r0], #4 // N set
strmi r1, [r0], #4 // N set
// fix the remaining len
sub r2, r2, r3, lsr #28
// do the large memset
b .L_bigset
+6
View File
@@ -0,0 +1,6 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
OBJS += \
$(LOCAL_DIR)/string_tests.o \
$(LOCAL_DIR)/mymemcpy.o \
$(LOCAL_DIR)/mymemset.o
+249
View File
@@ -0,0 +1,249 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <string.h>
#include <malloc.h>
#include <app.h>
#include <platform.h>
#include <kernel/thread.h>
static uint8_t *src;
static uint8_t *dst;
static uint8_t *src2;
static uint8_t *dst2;
#define BUFFER_SIZE (1024*1024)
#define ITERATIONS 16
extern void *mymemcpy(void *dst, const void *src, size_t len);
extern void *mymemset(void *dst, int c, size_t len);
static void *null_memcpy(void *dst, const void *src, size_t len)
{
return dst;
}
static time_t bench_memcpy_routine(void *memcpy_routine(void *, const void *, size_t), size_t srcalign, size_t dstalign)
{
int i;
time_t t0;
t0 = current_time();
for (i=0; i < ITERATIONS; i++) {
memcpy_routine(dst + dstalign, src + srcalign, BUFFER_SIZE);
}
return current_time() - t0;
}
static void bench_memcpy(void)
{
time_t null, libc, mine;
size_t srcalign, dstalign;
printf("memcpy speed test\n");
thread_sleep(200); // let the debug string clear the serial port
for (srcalign = 0; srcalign < 64; ) {
for (dstalign = 0; dstalign < 64; ) {
null = bench_memcpy_routine(&null_memcpy, srcalign, dstalign);
libc = bench_memcpy_routine(&memcpy, srcalign, dstalign);
mine = bench_memcpy_routine(&mymemcpy, srcalign, dstalign);
printf("srcalign %lu, dstalign %lu\n", srcalign, dstalign);
printf(" null memcpy %u msecs\n", null);
printf(" libc memcpy %u msecs, %llu bytes/sec\n", libc, BUFFER_SIZE * ITERATIONS * 1000ULL / libc);
printf(" my memcpy %u msecs, %llu bytes/sec\n", mine, BUFFER_SIZE * ITERATIONS * 1000ULL / mine);
if (dstalign == 0)
dstalign = 1;
else
dstalign <<= 1;
}
if (srcalign == 0)
srcalign = 1;
else
srcalign <<= 1;
}
}
static void fillbuf(void *ptr, size_t len, uint32_t seed)
{
size_t i;
for (i = 0; i < len; i++) {
((char *)ptr)[i] = seed;
seed *= 0x1234567;
}
}
static void validate_memcpy(void)
{
size_t srcalign, dstalign, size;
const size_t maxsize = 256;
printf("testing memcpy for correctness\n");
/*
* do the simple tests to make sure that memcpy doesn't color outside
* the lines for all alignment cases
*/
for (srcalign = 0; srcalign < 64; srcalign++) {
for (dstalign = 0; dstalign < 64; dstalign++) {
// printf("srcalign %zu, dstalign %zu\n", srcalign, dstalign);
for (size = 0; size < maxsize; size++) {
// printf("srcalign %zu, dstalign %zu, size %zu\n", srcalign, dstalign, size);
fillbuf(src, maxsize * 2, 567);
fillbuf(src2, maxsize * 2, 567);
fillbuf(dst, maxsize * 2, 123514);
fillbuf(dst2, maxsize * 2, 123514);
memcpy(dst + dstalign, src + srcalign, size);
mymemcpy(dst2 + dstalign, src2 + srcalign, size);
int comp = memcmp(dst, dst2, maxsize * 2);
if (comp != 0) {
printf("error! srcalign %zu, dstalign %zu, size %zu\n", srcalign, dstalign, size);
}
}
}
}
}
static time_t bench_memset_routine(void *memset_routine(void *, int, size_t), size_t dstalign)
{
int i;
time_t t0;
t0 = current_time();
for (i=0; i < ITERATIONS; i++) {
memset_routine(dst + dstalign, 0, BUFFER_SIZE);
}
return current_time() - t0;
}
static void bench_memset(void)
{
time_t libc, mine;
size_t dstalign;
printf("memset speed test\n");
thread_sleep(200); // let the debug string clear the serial port
for (dstalign = 0; dstalign < 64; dstalign++) {
libc = bench_memset_routine(&memset, dstalign);
mine = bench_memset_routine(&mymemset, dstalign);
printf("dstalign %lu\n", dstalign);
printf(" libc memset %u msecs, %llu bytes/sec\n", libc, BUFFER_SIZE * ITERATIONS * 1000ULL / libc);
printf(" my memset %u msecs, %llu bytes/sec\n", mine, BUFFER_SIZE * ITERATIONS * 1000ULL / mine);
}
}
static void validate_memset(void)
{
size_t dstalign, size;
int c;
const size_t maxsize = 256;
printf("testing memset for correctness\n");
for (dstalign = 0; dstalign < 64; dstalign++) {
printf("align %zd\n", dstalign);
for (size = 0; size < maxsize; size++) {
for (c = 0; c < 256; c++) {
fillbuf(dst, maxsize * 2, 123514);
fillbuf(dst2, maxsize * 2, 123514);
memset(dst + dstalign, c, size);
mymemset(dst2 + dstalign, c, size);
int comp = memcmp(dst, dst2, maxsize * 2);
if (comp != 0) {
printf("error! align %zu, c %d, size %zu\n", dstalign, c, size);
}
}
}
}
}
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
static int string_tests(int argc, cmd_args *argv)
{
src = memalign(64, BUFFER_SIZE + 256);
dst = memalign(64, BUFFER_SIZE + 256);
src2 = memalign(64, BUFFER_SIZE + 256);
dst2 = memalign(64, BUFFER_SIZE + 256);
printf("src %p, dst %p\n", src, dst);
printf("src2 %p, dst2 %p\n", src2, dst2);
if (argc < 3) {
printf("not enough arguments:\n");
usage:
printf("%s validate <routine>\n", argv[0].str);
printf("%s bench <routine>\n", argv[0].str);
goto out;
}
if (!strcmp(argv[1].str, "validate")) {
if (!strcmp(argv[2].str, "memcpy")) {
validate_memcpy();
} else if (!strcmp(argv[2].str, "memset")) {
validate_memset();
}
} else if (!strcmp(argv[1].str, "bench")) {
if (!strcmp(argv[2].str, "memcpy")) {
bench_memcpy();
} else if (!strcmp(argv[2].str, "memset")) {
bench_memset();
}
} else {
goto usage;
}
out:
free(src);
free(dst);
free(src2);
free(dst2);
return 0;
}
STATIC_COMMAND_START
{ "string", NULL, &string_tests },
STATIC_COMMAND_END(stringtests);
#endif
APP_START(stringtests)
APP_END
+30
View File
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __APP_TESTS_H
#define __APP_TESTS_H
int thread_tests(void);
void printf_tests(void);
#endif
+90
View File
@@ -0,0 +1,90 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <app/tests.h>
#include <debug.h>
void printf_tests(void)
{
printf("printf tests\n");
printf("numbers:\n");
printf("int8: %hhd %hhd %hhd\n", -12, 0, 254);
printf("uint8: %hhu %hhu %hhu\n", -12, 0, 254);
printf("int16: %hd %hd %hd\n", -1234, 0, 1234);
printf("uint16:%hu %hu %hu\n", -1234, 0, 1234);
printf("int: %d %d %d\n", -12345678, 0, 12345678);
printf("uint: %u %u %u\n", -12345678, 0, 12345678);
printf("long: %ld %ld %ld\n", -12345678, 0, 12345678);
printf("ulong: %lu %lu %lu\n", -12345678, 0, 12345678);
printf("long: %D %D %D\n", -12345678, 0, 12345678);
printf("ulong: %U %U %U\n", -12345678, 0, 12345678);
printf("longlong: %lli %lli %lli\n", -12345678LL, 0LL, 12345678LL);
printf("ulonglong: %llu %llu %llu\n", -12345678LL, 0LL, 12345678LL);
printf("size_t: %zd %zd %zd\n", -12345678, 0, 12345678);
printf("usize_t: %zu %zu %zu\n", -12345678, 0, 12345678);
printf("hex:\n");
printf("uint8: %hhx %hhx %hhx\n", -12, 0, 254);
printf("uint16:%hx %hx %hx\n", -1234, 0, 1234);
printf("uint: %x %x %x\n", -12345678, 0, 12345678);
printf("ulong: %lx %lx %lx\n", -12345678, 0, 12345678);
printf("ulong: %X %X %X\n", -12345678, 0, 12345678);
printf("ulonglong: %llx %llx %llx\n", -12345678LL, 0LL, 12345678LL);
printf("usize_t: %zx %zx %zx\n", -12345678, 0, 12345678);
printf("alt/sign:\n");
printf("uint: %#x %#X\n", 0xabcdef, 0xabcdef);
printf("int: %+d %+d\n", 12345678, -12345678);
printf("formatting\n");
printf("int: a%8da\n", 12345678);
printf("int: a%9da\n", 12345678);
printf("int: a%-9da\n", 12345678);
printf("int: a%10da\n", 12345678);
printf("int: a%-10da\n", 12345678);
printf("int: a%09da\n", 12345678);
printf("int: a%010da\n", 12345678);
printf("int: a%6da\n", 12345678);
printf("a%1sa\n", "b");
printf("a%9sa\n", "b");
printf("a%-9sa\n", "b");
printf("a%5sa\n", "thisisatest");
int err;
err = printf("a");
printf(" returned %d\n", err);
err = printf("ab");
printf(" returned %d\n", err);
err = printf("abc");
printf(" returned %d\n", err);
err = printf("abcd");
printf(" returned %d\n", err);
err = printf("abcde");
printf(" returned %d\n", err);
err = printf("abcdef");
printf(" returned %d\n", err);
}
+8
View File
@@ -0,0 +1,8 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include
OBJS += \
$(LOCAL_DIR)/tests.o \
$(LOCAL_DIR)/thread_tests.o \
$(LOCAL_DIR)/printf_tests.o
+46
View File
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <app.h>
#include <debug.h>
#include <app/tests.h>
#include <compiler.h>
#if defined(WITH_LIB_CONSOLE)
#include <lib/console.h>
STATIC_COMMAND_START
STATIC_COMMAND("printf_tests", NULL, (console_cmd)&printf_tests)
STATIC_COMMAND("thread_tests", NULL, (console_cmd)&thread_tests)
STATIC_COMMAND_END(tests);
#endif
static void tests_init(const struct app_descriptor *app)
{
}
APP_START(tests)
.init = tests_init,
.flags = 0,
APP_END
+322
View File
@@ -0,0 +1,322 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <rand.h>
#include <app/tests.h>
#include <kernel/thread.h>
#include <kernel/mutex.h>
#include <kernel/event.h>
static int sleep_thread(void *arg)
{
for(;;) {
printf("sleeper %p\n", current_thread);
thread_sleep(rand() % 500);
}
return 0;
}
int sleep_test(void)
{
int i;
for(i=0; i < 16; i++)
thread_resume(thread_create("sleeper", &sleep_thread, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
return 0;
}
static volatile int shared = 0;
static mutex_t m;
static volatile int mutex_thread_count = 0;
static int mutex_thread(void *arg)
{
int i;
const int iterations = 10000;
atomic_add(&mutex_thread_count, 1);
printf("mutex tester thread %p starting up, will go for %d iterations\n", current_thread, iterations);
for (i = 0; i < iterations; i++) {
mutex_acquire(&m);
if (shared != 0)
panic("someone else has messed with the shared data\n");
shared = (int)current_thread;
thread_yield();
shared = 0;
mutex_release(&m);
thread_yield();
}
atomic_add(&mutex_thread_count, -1);
return 0;
}
static int mutex_timeout_thread(void *arg)
{
mutex_t *timeout_mutex = (mutex_t *)arg;
status_t err;
printf("mutex_timeout_thread acquiring mutex %p with 1 second timeout\n", timeout_mutex);
err = mutex_acquire_timeout(timeout_mutex, 1000);
printf("mutex_acquire_timeout returns %d\n", err);
return err;
}
static int mutex_zerotimeout_thread(void *arg)
{
mutex_t *timeout_mutex = (mutex_t *)arg;
status_t err;
printf("mutex_zerotimeout_thread acquiring mutex %p with zero second timeout\n", timeout_mutex);
err = mutex_acquire_timeout(timeout_mutex, 0);
printf("mutex_acquire_timeout returns %d\n", err);
return err;
}
int mutex_test(void)
{
mutex_init(&m);
int i;
for(i=0; i < 5; i++)
thread_resume(thread_create("mutex tester", &mutex_thread, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_sleep(1000);
while (mutex_thread_count > 0)
thread_yield();
printf("done with simple mutex tests\n");
printf("testing mutex timeout\n");
mutex_t timeout_mutex;
mutex_init(&timeout_mutex);
mutex_acquire(&timeout_mutex);
for (i=0; i < 2; i++)
thread_resume(thread_create("mutex timeout tester", &mutex_timeout_thread, (void *)&timeout_mutex, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
for (i=0; i < 2; i++)
thread_resume(thread_create("mutex timeout tester", &mutex_zerotimeout_thread, (void *)&timeout_mutex, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_sleep(5000);
mutex_release(&timeout_mutex);
printf("done with mutex tests\n");
mutex_destroy(&timeout_mutex);
return 0;
}
static event_t e;
static int event_signaller(void *arg)
{
printf("event signaller pausing\n");
thread_sleep(1000);
// for (;;) {
printf("signalling event\n");
event_signal(&e, true);
printf("done signalling event\n");
thread_yield();
// }
return 0;
}
static int event_waiter(void *arg)
{
printf("event waiter starting\n");
for (;;) {
printf("%p: waiting on event...\n", current_thread);
if (event_wait(&e) < 0) {
printf("%p: event_wait() returned error\n", current_thread);
return -1;
}
printf("%p: done waiting on event...\n", current_thread);
thread_yield();
}
return 0;
}
void event_test(void)
{
/* make sure signalling the event wakes up all the threads */
event_init(&e, false, 0);
thread_resume(thread_create("event signaller", &event_signaller, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 0", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 1", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 2", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 3", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_sleep(2000);
event_destroy(&e);
/* make sure signalling the event wakes up precisely one thread */
event_init(&e, false, EVENT_FLAG_AUTOUNSIGNAL);
thread_resume(thread_create("event signaller", &event_signaller, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 0", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 1", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 2", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("event waiter 3", &event_waiter, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_sleep(2000);
event_destroy(&e);
}
static int quantum_tester(void *arg)
{
for (;;) {
printf("%p: in this thread. rq %d\n", current_thread, current_thread->remaining_quantum);
}
return 0;
}
void quantum_test(void)
{
thread_resume(thread_create("quantum tester 0", &quantum_tester, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("quantum tester 1", &quantum_tester, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("quantum tester 2", &quantum_tester, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("quantum tester 3", &quantum_tester, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
}
static event_t context_switch_event;
static event_t context_switch_done_event;
static int context_switch_tester(void *arg)
{
int i;
uint total_count = 0;
const int iter = 100000;
int thread_count = (int)arg;
event_wait(&context_switch_event);
uint count = arch_cycle_count();
for (i = 0; i < iter; i++) {
thread_yield();
}
total_count += arch_cycle_count() - count;
thread_sleep(1000);
printf("took %u cycles to yield %d times, %u per yield, %u per yield per thread\n",
total_count, iter, total_count / iter, total_count / iter / thread_count);
event_signal(&context_switch_done_event, true);
return 0;
}
void context_switch_test(void)
{
event_init(&context_switch_event, false, 0);
event_init(&context_switch_done_event, false, 0);
thread_resume(thread_create("context switch idle", &context_switch_tester, (void *)1, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_sleep(100);
event_signal(&context_switch_event, true);
event_wait(&context_switch_done_event);
thread_sleep(100);
event_unsignal(&context_switch_event);
event_unsignal(&context_switch_done_event);
thread_resume(thread_create("context switch 2a", &context_switch_tester, (void *)2, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("context switch 2b", &context_switch_tester, (void *)2, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_sleep(100);
event_signal(&context_switch_event, true);
event_wait(&context_switch_done_event);
thread_sleep(100);
event_unsignal(&context_switch_event);
event_unsignal(&context_switch_done_event);
thread_resume(thread_create("context switch 4a", &context_switch_tester, (void *)4, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("context switch 4b", &context_switch_tester, (void *)4, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("context switch 4c", &context_switch_tester, (void *)4, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("context switch 4d", &context_switch_tester, (void *)4, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
thread_sleep(100);
event_signal(&context_switch_event, true);
event_wait(&context_switch_done_event);
thread_sleep(100);
}
static volatile int atomic;
static volatile int atomic_count;
static int atomic_tester(void *arg)
{
int add = (int)arg;
int i;
TRACEF("add %d\n", add);
for (i=0; i < 1000000; i++) {
atomic_add(&atomic, add);
}
int old = atomic_add(&atomic_count, -1);
TRACEF("exiting, old count %d\n", old);
return 0;
}
static void atomic_test(void)
{
atomic = 0;
atomic_count = 8;
thread_resume(thread_create("atomic tester 1", &atomic_tester, (void *)1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("atomic tester 1", &atomic_tester, (void *)1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("atomic tester 1", &atomic_tester, (void *)1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("atomic tester 1", &atomic_tester, (void *)1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("atomic tester 2", &atomic_tester, (void *)-1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("atomic tester 2", &atomic_tester, (void *)-1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("atomic tester 2", &atomic_tester, (void *)-1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
thread_resume(thread_create("atomic tester 2", &atomic_tester, (void *)-1, LOW_PRIORITY, DEFAULT_STACK_SIZE));
while (atomic_count > 0) {
thread_sleep(1);
}
printf("atomic count == %d (should be zero)\n", atomic);
}
int thread_tests(void)
{
mutex_test();
event_test();
thread_sleep(200);
context_switch_test();
atomic_test();
return 0;
}
+85
View File
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <arch.h>
#include <arch/ops.h>
#include <arch/arm.h>
#include <arch/arm/mmu.h>
#include <platform.h>
#if ARM_CPU_CORTEX_A8
static void set_vector_base(addr_t addr)
{
__asm__ volatile("mcr p15, 0, %0, c12, c0, 0" :: "r" (addr));
}
#endif
void arch_early_init(void)
{
/* turn off the cache */
arch_disable_cache(UCACHE);
/* set the vector base to our exception vectors so we dont need to double map at 0 */
#if ARM_CPU_CORTEX_A8
set_vector_base(MEMBASE);
#endif
#if ARM_WITH_MMU
arm_mmu_init();
platform_init_mmu_mappings();
#endif
/* turn the cache back on */
arch_enable_cache(UCACHE);
#if ARM_WITH_NEON
/* enable cp10 and cp11 */
uint32_t val;
__asm__ volatile("mrc p15, 0, %0, c1, c0, 2" : "=r" (val));
val |= (3<<22)|(3<<20);
__asm__ volatile("mcr p15, 0, %0, c1, c0, 2" :: "r" (val));
/* set enable bit in fpexc */
val = (1<<30);
__asm__ volatile("mcr p10, 7, %0, c8, c0, 0" :: "r" (val));
#endif
#if ARM_CPU_CORTEX_A8
/* enable the cycle count register */
uint32_t en;
__asm__ volatile("mrc p15, 0, %0, c9, c12, 0" : "=r" (en));
en &= ~(1<<3); /* cycle count every cycle */
en |= 1; /* enable all performance counters */
__asm__ volatile("mcr p15, 0, %0, c9, c12, 0" :: "r" (en));
/* enable cycle counter */
en = (1<<31);
__asm__ volatile("mcr p15, 0, %0, c9, c12, 1" :: "r" (en));
#endif
}
void arch_init(void)
{
}
+103
View File
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
/* context switch frame is as follows:
* ulr
* usp
* lr
* r11
* r10
* r9
* r8
* r7
* r6
* r5
* r4
*/
/* arm_context_switch(addr_t *old_sp, addr_t new_sp) */
FUNCTION(arm_context_switch)
/* save all the usual registers + user regs */
/* the spsr is saved and restored in the iframe by exceptions.S */
sub r3, sp, #(11*4) /* can't use sp in user mode stm */
mov r12, lr
stmia r3, { r4-r11, r12, r13, r14 }^
/* save old sp */
str r3, [r0]
/* clear any exlusive locks that the old thread holds */
#if ARM_ISA_ARMV7
/* can clear it directly */
.word 0xf57ff01f // clrex
#elif ARM_ISA_ARMV6
/* have to do a fake strex to clear it */
ldr r0, =strex_spot
strex r3, r2, [r0]
#endif
/* load new regs */
ldmia r1, { r4-r11, r12, r13, r14 }^
mov lr, r12 /* restore lr */
add sp, r1, #(11*4) /* restore sp */
bx lr
.ltorg
FUNCTION(arm_save_mode_regs)
mrs r1, cpsr
#if ARM_ISA_ARMv6
cps #0x11 /* fiq */
str r13, [r0], #4
str r14, [r0], #4
cps #0x12 /* irq */
str r13, [r0], #4
str r14, [r0], #4
cps #0x13 /* svc */
str r13, [r0], #4
str r14, [r0], #4
cps #0x17 /* abt */
str r13, [r0], #4
str r14, [r0], #4
cps #0x1b /* und */
str r13, [r0], #4
str r14, [r0], #4
cps #0x1f /* sys */
str r13, [r0], #4
str r14, [r0], #4
#else
// XXX implement
b .
#endif
msr cpsr_c, r1
bx lr
.data
strex_spot:
.word 0
+380
View File
@@ -0,0 +1,380 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
#include <arch/ops.h>
#include <arch/defines.h>
.text
#if ARM_WITH_CACHE
/* low level cache routines for various cpu families */
#if ARM_CPU_ARM1136 || ARM_CPU_ARM926
/* void arch_disable_cache(uint flags) */
FUNCTION(arch_disable_cache)
mov r12, #0 // zero register
mrs r3, cpsr // save the old interrupt state
#if ARM_ISA_ARMv6
.word 0xf10c01c0 /* cpsid iaf */ // interrupts disabled
#else
orr r3, r3, #(1<<7)
msr cpsr, r3
#endif
.Ldcache_disable:
tst r0, #DCACHE
beq .Licache_disable
mrc p15, 0, r1, c1, c0, 0 // cr1
tst r1, #(1<<2) // is the dcache already disabled?
beq .Licache_disable
bic r1, #(1<<2)
mcr p15, 0, r1, c1, c0, 0 // disable dcache
#if ARM_CPU_ARM1136
mcr p15, 0, r12, c7, c14, 0 // clean & invalidate dcache
#elif ARM_CPU_ARM926
0:
mrc p15, 0, r15, c7, c14, 3 // clean & invalidate dcache
bne 0b
#else
#error whut?
#endif
mcr p15, 0, r0, c7, c10, 4 // data sync barrier (formerly drain write buffer)
.Licache_disable:
tst r0, #ICACHE
beq .Ldone_disable
mrc p15, 0, r1, c1, c0, 0 // cr1
bic r1, #(1<<12)
mcr p15, 0, r1, c1, c0, 0 // disable icache
mcr p15, 0, r12, c7, c5, 0 // invalidate icache
.Ldone_disable:
msr cpsr, r3
bx lr
/* void arch_enable_cache(uint flags) */
FUNCTION(arch_enable_cache)
mov r12, #0 // zero register
mrs r3, cpsr // save the old interrupt state
#if ARM_ISA_ARMv6
.word 0xf10c01c0 /* cpsid iaf */ // interrupts disabled
#else
orr r3, r3, #(1<<7)
msr cpsr, r3
#endif
.Ldcache_enable:
tst r0, #DCACHE
beq .Licache_enable
mrc p15, 0, r1, c1, c0, 0 // cr1
tst r1, #(1<<2) // is the dcache already enabled?
bne .Licache_enable
mcr p15, 0, r12, c7, c6, 0 // invalidate dcache
orr r1, #(1<<2)
mcr p15, 0, r1, c1, c0, 0 // enable dcache
.Licache_enable:
tst r0, #ICACHE
beq .Ldone_enable
mcr p15, 0, r12, c7, c5, 0 // invalidate icache
mrc p15, 0, r1, c1, c0, 0 // cr1
orr r1, #(1<<12)
mcr p15, 0, r1, c1, c0, 0 // enable icache
.Ldone_enable:
msr cpsr, r3
bx lr
#elif ARM_CPU_CORTEX_A8
/* void arch_disable_cache(uint flags) */
FUNCTION(arch_disable_cache)
stmfd sp!, {r4-r11, lr}
mov r7, r0 // save flags
mrs r12, cpsr // save the old interrupt state
.word 0xf10c01c0 /* cpsid iaf */ // interrupts disabled
.Ldcache_disable:
tst r7, #DCACHE
beq .Licache_disable
mrc p15, 0, r0, c1, c0, 0 // cr1
tst r0, #(1<<2) // is the dcache already disabled?
beq .Ldcache_already_disabled
bic r0, #(1<<2)
mcr p15, 0, r0, c1, c0, 0 // disable dcache
// flush and invalidate the dcache
// NOTE: trashes a bunch of registers, can't be spilling stuff to the stack
bl flush_invalidate_cache_v7
b .Ldcache_disable_L2
.Ldcache_already_disabled:
// make sure all of the caches are invalidated
// NOTE: trashes a bunch of registers, can't be spilling stuff to the stack
bl invalidate_cache_v7
.Ldcache_disable_L2:
#if ARM_WITH_L2
// disable the L2, if present
mrc p15, 0, r0, c1, c0, 1 // aux cr1
bic r0, #(1<<1)
mcr p15, 0, r0, c1, c0, 1 // disable L2 dcache
#endif
.Licache_disable:
tst r7, #ICACHE
beq .Ldone_disable
mrc p15, 0, r0, c1, c0, 0 // cr1
bic r0, #(1<<12)
mcr p15, 0, r0, c1, c0, 0 // disable icache
.Ldone_disable:
// make sure the icache is always invalidated
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 // invalidate icache to PoU
msr cpsr, r12
ldmfd sp!, {r4-r11, pc}
/* void arch_enable_cache(uint flags) */
FUNCTION(arch_enable_cache)
stmfd sp!, {r4-r11, lr}
mov r7, r0 // save flags
mrs r12, cpsr // save the old interrupt state
.word 0xf10c01c0 /* cpsid iaf */ // interrupts disabled
.Ldcache_enable:
tst r7, #DCACHE
beq .Licache_enable
mrc p15, 0, r0, c1, c0, 0 // cr1
tst r0, #(1<<2) // is the dcache already enabled?
bne .Licache_enable
// invalidate L1 and L2
// NOTE: trashes a bunch of registers, can't be spilling stuff to the stack
bl invalidate_cache_v7
#if ARM_WITH_L2
// enable the L2, if present
mrc p15, 0, r0, c1, c0, 1 // aux cr1
orr r0, #(1<<1)
mcr p15, 0, r0, c1, c0, 1 // enable L2 dcache
#endif
mrc p15, 0, r0, c1, c0, 0 // cr1
orr r0, #(1<<2)
mcr p15, 0, r0, c1, c0, 0 // enable dcache
.Licache_enable:
tst r7, #ICACHE
beq .Ldone_enable
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 // invalidate icache to PoU
mrc p15, 0, r0, c1, c0, 0 // cr1
orr r0, #(1<<12)
mcr p15, 0, r0, c1, c0, 0 // enable icache
.Ldone_enable:
msr cpsr, r12
ldmfd sp!, {r4-r11, pc}
// flush & invalidate cache routine, trashes r0-r6, r9-r11
flush_invalidate_cache_v7:
/* from ARMv7 manual, B2-17 */
MRC p15, 1, R0, c0, c0, 1 // Read CLIDR
ANDS R3, R0, #0x7000000
MOV R3, R3, LSR #23 // Cache level value (naturally aligned)
BEQ .Lfinished
MOV R10, #0
.Loop1:
ADD R2, R10, R10, LSR #1 // Work out 3xcachelevel
MOV R1, R0, LSR R2 // bottom 3 bits are the Cache type for this level
AND R1, R1, #7 // get those 3 bits alone
CMP R1, #2
BLT .Lskip // no cache or only instruction cache at this level
MCR p15, 2, R10, c0, c0, 0 // write the Cache Size selection register
.word 0xf57ff06f // ISB // ISB to sync the change to the CacheSizeID reg
MRC p15, 1, R1, c0, c0, 0 // reads current Cache Size ID register
AND R2, R1, #0x7 // extract the line length field
ADD R2, R2, #4 // add 4 for the line length offset (log2 16 bytes)
LDR R4, =0x3FF
ANDS R4, R4, R1, LSR #3 // R4 is the max number on the way size (right aligned)
CLZ R5, R4 // R5 is the bit position of the way size increment
LDR R6, =0x00007FFF
ANDS R6, R6, R1, LSR #13 // R6 is the max number of the index size (right aligned)
.Loop2:
MOV R9, R4 // R9 working copy of the max way size (right aligned)
.Loop3:
ORR R11, R10, R9, LSL R5 // factor in the way number and cache number into R11
ORR R11, R11, R6, LSL R2 // factor in the index number
MCR p15, 0, R11, c7, c14, 2 // clean & invalidate by set/way
SUBS R9, R9, #1 // decrement the way number
BGE .Loop3
SUBS R6, R6, #1 // decrement the index
BGE .Loop2
.Lskip:
ADD R10, R10, #2 // increment the cache number
CMP R3, R10
BGT .Loop1
.Lfinished:
mov r10, #0
mcr p15, 2, r10, c0, c0, 0 // select cache level 0
.word 0xf57ff06f // isb
bx lr
// invalidate cache routine, trashes r0-r6, r9-r11
invalidate_cache_v7:
/* from ARMv7 manual, B2-17 */
MRC p15, 1, R0, c0, c0, 1 // Read CLIDR
ANDS R3, R0, #0x7000000
MOV R3, R3, LSR #23 // Cache level value (naturally aligned)
BEQ .Lfinished_invalidate
MOV R10, #0
.Loop1_invalidate:
ADD R2, R10, R10, LSR #1 // Work out 3xcachelevel
MOV R1, R0, LSR R2 // bottom 3 bits are the Cache type for this level
AND R1, R1, #7 // get those 3 bits alone
CMP R1, #2
BLT .Lskip_invalidate // no cache or only instruction cache at this level
MCR p15, 2, R10, c0, c0, 0 // write the Cache Size selection register
.word 0xf57ff06f // ISB // ISB to sync the change to the CacheSizeID reg
MRC p15, 1, R1, c0, c0, 0 // reads current Cache Size ID register
AND R2, R1, #0x7 // extract the line length field
ADD R2, R2, #4 // add 4 for the line length offset (log2 16 bytes)
LDR R4, =0x3FF
ANDS R4, R4, R1, LSR #3 // R4 is the max number on the way size (right aligned)
CLZ R5, R4 // R5 is the bit position of the way size increment
LDR R6, =0x00007FFF
ANDS R6, R6, R1, LSR #13 // R6 is the max number of the index size (right aligned)
.Loop2_invalidate:
MOV R9, R4 // R9 working copy of the max way size (right aligned)
.Loop3_invalidate:
ORR R11, R10, R9, LSL R5 // factor in the way number and cache number into R11
ORR R11, R11, R6, LSL R2 // factor in the index number
MCR p15, 0, R11, c7, c6, 2 // invalidate by set/way
SUBS R9, R9, #1 // decrement the way number
BGE .Loop3_invalidate
SUBS R6, R6, #1 // decrement the index
BGE .Loop2_invalidate
.Lskip_invalidate:
ADD R10, R10, #2 // increment the cache number
CMP R3, R10
BGT .Loop1_invalidate
.Lfinished_invalidate:
mov r10, #0
mcr p15, 2, r10, c0, c0, 0 // select cache level 0
.word 0xf57ff06f // isb
bx lr
#else
#error unhandled cpu
#endif
#if ARM_CPU_ARM926 || ARM_CPU_ARM1136 || ARM_CPU_CORTEX_A8
/* shared cache flush routines */
/* void arch_flush_cache_range(addr_t start, size_t len); */
FUNCTION(arch_clean_cache_range)
0:
mcr p15, 0, r0, c7, c10, 1 // clean cache to PoC by MVA
add r0, r0, #CACHE_LINE
subs r1, r1, #CACHE_LINE
bhs 0b
mov r0, #0
mcr p15, 0, r0, c7, c10, 4 // data sync barrier (formerly drain write buffer)
bx lr
/* void arch_flush_invalidate_cache_range(addr_t start, size_t len); */
FUNCTION(arch_clean_invalidate_cache_range)
0:
mcr p15, 0, r0, c7, c14, 1 // clean & invalidate cache to PoC by MVA
add r0, r0, #CACHE_LINE
subs r1, r1, #CACHE_LINE
bhs 0b
mov r0, #0
mcr p15, 0, r0, c7, c10, 4 // data sync barrier (formerly drain write buffer)
bx lr
/* void arch_sync_cache_range(addr_t start, size_t len); */
FUNCTION(arch_sync_cache_range)
push { r14 }
bl arch_clean_cache_range
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 // invalidate icache to PoU
pop { pc }
#else
#error unhandled cpu
#endif
#else
/* no cache */
FUNCTION(arch_disable_cache)
bx lr
FUNCTION(arch_enable_cache)
bx lr
FUNCTION(arch_clean_cache_range)
bx lr
FUNCTION(arch_clean_invalidate_cache_range)
bx lr
FUNCTION(arch_sync_cache_range)
bx lr
#endif // ARM_WITH_CACHE
+22
View File
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+39
View File
@@ -0,0 +1,39 @@
$(BUILDDIR)/%.o: %.c $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) $(THUMBCFLAGS) --std=c99 $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.o: %.cpp $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) $(CPPFLAGS) $(THUMBCFLAGS) $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
# to override thumb setting, mark the .o file as .Ao
$(BUILDDIR)/%.Ao: %.c $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) --std=c99 $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.Ao: %.cpp $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
# assembly is always compiled in ARM mode at the moment
$(BUILDDIR)/%.Ao: %.S $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) $(ASMFLAGS) $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
ifeq ($(ENABLE_TRUSTZONE), 1)
$(BUILDDIR)/%.o: %.S $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) -DENABLE_TRUSTZONE $(CFLAGS) $(ASMFLAGS) $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
else
$(BUILDDIR)/%.o: %.S $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) $(ASMFLAGS) $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
endif
+213
View File
@@ -0,0 +1,213 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define DSB .byte 0x4f, 0xf0, 0x7f, 0xf5
#define ISB .byte 0x6f, 0xf0, 0x7f, 0xf5
.section ".text.boot"
.globl _start
_start:
b reset
b arm_undefined
b arm_syscall
b arm_prefetch_abort
b arm_data_abort
b arm_reserved
b arm_irq
b arm_fiq
reset:
#ifdef HANDLE_LINUX_KERNEL_ARGS
/* save (possible) linux kernel args to pass to kmain */
mov r8, r0
mov r9, r1
mov r10, r2
#endif
#ifdef ENABLE_TRUSTZONE
/*Add reference to TZ symbol so linker includes it in final image */
ldr r7, =_binary_tzbsp_tzbsp_bin_start
#endif
/* do some cpu setup */
#if ARM_WITH_CP15
/* Read SCTLR */
mrc p15, 0, r0, c1, c0, 0
/* XXX this is currently for arm926, revist with armv6 cores */
/* new thumb behavior, low exception vectors, i/d cache disable, mmu disabled */
bic r0, r0, #(1<<15| 1<<13 | 1<<12)
bic r0, r0, #(1<<2 | 1<<0)
/* enable alignment faults */
orr r0, r0, #(1<<1)
/* Write SCTLR */
mcr p15, 0, r0, c1, c0, 0
#ifdef ENABLE_TRUSTZONE
/*nkazi: not needed ? Setting VBAR to location of new vector table : 0x80000 */
ldr r0, =0x00080000
mcr p15, 0, r0, c12, c0, 0
#endif
#endif
#if WITH_CPU_EARLY_INIT
/* call platform/arch/etc specific init code */
#ifndef ENABLE_TRUSTZONE
/* Not needed when TrustZone is the first bootloader that runs.*/
bl __cpu_early_init
#endif
/* declare return address as global to avoid using stack */
.globl _cpu_early_init_complete
_cpu_early_init_complete:
#endif
#if (!ENABLE_NANDWRITE)
#if WITH_CPU_WARM_BOOT
ldr r0, warm_boot_tag
cmp r0, #1
/* if set, warm boot */
ldreq pc, =BASE_ADDR
mov r0, #1
str r0, warm_boot_tag
#endif
#endif
/* see if we need to relocate */
mov r0, pc
sub r0, r0, #(.Laddr - _start)
.Laddr:
ldr r1, =_start
cmp r0, r1
beq .Lstack_setup
/* we need to relocate ourselves to the proper spot */
ldr r2, =__data_end
.Lrelocate_loop:
ldr r3, [r0], #4
str r3, [r1], #4
cmp r1, r2
bne .Lrelocate_loop
/* we're relocated, jump to the right address */
ldr r0, =.Lstack_setup
bx r0
.ltorg
#if WITH_CPU_WARM_BOOT
warm_boot_tag:
.word 0
#endif
.Lstack_setup:
/* set up the stack for irq, fiq, abort, undefined, system/user, and lastly supervisor mode */
mrs r0, cpsr
bic r0, r0, #0x1f
ldr r2, =abort_stack_top
orr r1, r0, #0x12 // irq
msr cpsr_c, r1
ldr r13, =irq_save_spot /* save a pointer to a temporary dumping spot used during irq delivery */
orr r1, r0, #0x11 // fiq
msr cpsr_c, r1
mov sp, r2
orr r1, r0, #0x17 // abort
msr cpsr_c, r1
mov sp, r2
orr r1, r0, #0x1b // undefined
msr cpsr_c, r1
mov sp, r2
orr r1, r0, #0x1f // system
msr cpsr_c, r1
mov sp, r2
orr r1, r0, #0x13 // supervisor
msr cpsr_c, r1
mov sp, r2
/* copy the initialized data segment out of rom if necessary */
ldr r0, =__data_start_rom
ldr r1, =__data_start
ldr r2, =__data_end
cmp r0, r1
beq .L__do_bss
.L__copy_loop:
cmp r1, r2
ldrlt r3, [r0], #4
strlt r3, [r1], #4
blt .L__copy_loop
.L__do_bss:
/* clear out the bss */
ldr r0, =__bss_start
ldr r1, =_end
mov r2, #0
.L__bss_loop:
cmp r0, r1
strlt r2, [r0], #4
blt .L__bss_loop
#ifdef ARM_CPU_CORTEX_A8
DSB
ISB
#endif
#ifdef HANDLE_LINUX_KERNEL_ARGS
/* pass (possible) linux kernel args to kmain */
mov r0, r8
mov r1, r9
mov r2, r10
#endif
bl kmain
b .
.ltorg
.bss
.align 2
/* the abort stack is for unrecoverable errors.
* also note the initial working stack is set to here.
* when the threading system starts up it'll switch to a new
* dynamically allocated stack, so we don't need it for very long
*/
abort_stack:
.skip 1024
abort_stack_top:
.rodata:
.align 2
/* define the heap end as read-only data containing the end defined in the
* linker script. other archs that use dynamic memory length discovery can make
* this read-write and update it during init.
*/
.global _heap_end
_heap_end:
.int _end_of_ram
+41
View File
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2008 Brian Swetland
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
.global dcc_putc
.global dcc_getc
#if defined(ARM_ISA_ARMV6) || defined(ARM_ISA_ARMV7)
dcc_getc:
mrc 14, 0, r0, c0, c1, 0
tst r0, #(1 << 30)
moveq r0, #-1
mrcne 14, 0, r0, c0, c5, 0
bx lr
dcc_putc:
mrc 14, 0, r15, c0, c1, 0
mcrcc 14, 0, r0, c0, c5, 0
movcc r0, #0
movcs r0, #-1
bx lr
#endif
+132
View File
@@ -0,0 +1,132 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
FUNCTION(arm_undefined)
stmfd sp!, { r0-r12, r14 }
sub sp, sp, #12
mov r0, sp
mrs r1, spsr
stmia r0, { r1, r13-r14 }^
b arm_undefined_handler
b .
FUNCTION(arm_syscall)
stmfd sp!, { r0-r12, r14 }
sub sp, sp, #12
mov r0, sp
mrs r1, spsr
stmia r0, { r1, r13-r14 }^
b arm_syscall_handler
b .
FUNCTION(arm_prefetch_abort)
stmfd sp!, { r0-r12, r14 }
sub sp, sp, #12
mov r0, sp
mrs r1, spsr
stmia r0, { r1, r13-r14 }^
b arm_prefetch_abort_handler
b .
FUNCTION(arm_data_abort)
stmfd sp!, { r0-r12, r14 }
sub sp, sp, #12
mov r0, sp
mrs r1, spsr
stmia r0, { r1, r13-r14 }^
b arm_data_abort_handler
b .
FUNCTION(arm_reserved)
b .
FUNCTION(arm_irq)
/* XXX only deals with interrupting supervisor mode */
/* save r4-r6 and use as a temporary place to save while we switch into supervisor mode */
stmia r13, { r4-r6 }
mov r4, r13
sub r5, lr, #4
mrs r6, spsr
/* move into supervisor mode. irq/fiq disabled */
msr cpsr_c, #(3<<6 | 0x13)
/* save the return address */
stmfd sp!, { r5 }
/* save C trashed regs, supervisor lr */
stmfd sp!, { r0-r3, r12, lr }
/* save spsr */
stmfd sp!, { r6 }
/* restore r4-r6 */
ldmia r4, { r4-r6 }
/* increment the global critical section count */
ldr r1, =critical_section_count
ldr r0, [r1]
add r0, r0, #1
str r0, [r1]
/* call into higher level code */
mov r0, sp /* iframe */
bl platform_irq
/* reschedule if the handler returns nonzero */
cmp r0, #0
blne thread_preempt
/* decrement the global critical section count */
ldr r1, =critical_section_count
ldr r0, [r1]
sub r0, r0, #1
str r0, [r1]
/* restore spsr */
ldmfd sp!, { r0 }
msr spsr_cxsf, r0
/* restore back to where we came from */
ldmfd sp!, { r0-r3, r12, lr, pc }^
.bss
.align 2
.global irq_save_spot
irq_save_spot:
.word 0 /* r4 */
.word 0 /* r5 */
.word 0 /* r6 */
.text
FUNCTION(arm_fiq)
sub lr, lr, #4
stmfd sp!, { r0-r3, r12, lr }
bl platform_fiq
ldmfd sp!, { r0-r3, r12, pc }^
.ltorg
+91
View File
@@ -0,0 +1,91 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <arch/arm.h>
#include <kernel/thread.h>
static void dump_fault_frame(struct arm_fault_frame *frame)
{
dprintf(CRITICAL, "r0 0x%08x r1 0x%08x r2 0x%08x r3 0x%08x\n", frame->r[0], frame->r[1], frame->r[2], frame->r[3]);
dprintf(CRITICAL, "r4 0x%08x r5 0x%08x r6 0x%08x r7 0x%08x\n", frame->r[4], frame->r[5], frame->r[6], frame->r[7]);
dprintf(CRITICAL, "r8 0x%08x r9 0x%08x r10 0x%08x r11 0x%08x\n", frame->r[8], frame->r[9], frame->r[10], frame->r[11]);
dprintf(CRITICAL, "r12 0x%08x usp 0x%08x ulr 0x%08x pc 0x%08x\n", frame->r[12], frame->usp, frame->ulr, frame->pc);
dprintf(CRITICAL, "spsr 0x%08x\n", frame->spsr);
struct arm_mode_regs regs;
arm_save_mode_regs(&regs);
dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_FIQ) ? '*' : ' ', "fiq", regs.fiq_r13, regs.fiq_r14);
dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_IRQ) ? '*' : ' ', "irq", regs.irq_r13, regs.irq_r14);
dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SVC) ? '*' : ' ', "svc", regs.svc_r13, regs.svc_r14);
dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_UND) ? '*' : ' ', "und", regs.und_r13, regs.und_r14);
dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SYS) ? '*' : ' ', "sys", regs.sys_r13, regs.sys_r14);
// dump the bottom of the current stack
addr_t stack;
switch (frame->spsr & MODE_MASK) {
case MODE_FIQ: stack = regs.fiq_r13; break;
case MODE_IRQ: stack = regs.irq_r13; break;
case MODE_SVC: stack = regs.svc_r13; break;
case MODE_UND: stack = regs.und_r13; break;
case MODE_SYS: stack = regs.sys_r13; break;
default:
stack = 0;
}
if (stack != 0) {
dprintf(CRITICAL, "bottom of stack at 0x%08x:\n", (unsigned int)stack);
hexdump((void *)stack, 128);
}
}
static void exception_die(struct arm_fault_frame *frame, int pc_off, const char *msg)
{
inc_critical_section();
frame->pc += pc_off;
dprintf(CRITICAL, msg);
dump_fault_frame(frame);
halt();
for(;;);
}
void arm_syscall_handler(struct arm_fault_frame *frame)
{
exception_die(frame, -4, "unhandled syscall, halting\n");
}
void arm_undefined_handler(struct arm_fault_frame *frame)
{
exception_die(frame, -4, "undefined abort, halting\n");
}
void arm_data_abort_handler(struct arm_fault_frame *frame)
{
exception_die(frame, -8, "data abort, halting\n");
}
void arm_prefetch_abort_handler(struct arm_fault_frame *frame)
{
exception_die(frame, -4, "prefetch abort, halting\n");
}
+31
View File
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARM_ARCH_THREAD_H
#define __ARM_ARCH_THREAD_H
struct arch_thread {
vaddr_t sp;
};
#endif
+94
View File
@@ -0,0 +1,94 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_ARM_H
#define __ARCH_ARM_H
#include <sys/types.h>
#include <arch/arm/cores.h>
#if defined(__cplusplus)
extern "C" {
#endif
void arm_context_switch(vaddr_t *old_sp, vaddr_t new_sp);
static inline uint32_t read_cpsr() {
uint32_t cpsr;
__asm__ volatile("mrs %0, cpsr" : "=r" (cpsr));
return cpsr;
}
struct arm_iframe {
uint32_t spsr;
uint32_t r0;
uint32_t r1;
uint32_t r2;
uint32_t r3;
uint32_t r12;
uint32_t lr;
uint32_t pc;
};
struct arm_fault_frame {
uint32_t spsr;
uint32_t usp;
uint32_t ulr;
uint32_t r[13];
uint32_t pc;
};
#define MODE_MASK 0x1f
#define MODE_USR 0x10
#define MODE_FIQ 0x11
#define MODE_IRQ 0x12
#define MODE_SVC 0x13
#define MODE_MON 0x16
#define MODE_ABT 0x17
#define MODE_UND 0x1b
#define MODE_SYS 0x1f
struct arm_mode_regs {
uint32_t fiq_r13, fiq_r14;
uint32_t irq_r13, irq_r14;
uint32_t svc_r13, svc_r14;
uint32_t abt_r13, abt_r14;
uint32_t und_r13, und_r14;
uint32_t sys_r13, sys_r14;
};
void arm_save_mode_regs(struct arm_mode_regs *regs);
uint32_t arm_read_cr1(void);
void arm_write_cr1(uint32_t val);
uint32_t arm_read_cr1_aux(void);
void arm_write_cr1_aux(uint32_t val);
void arm_write_ttbr(uint32_t val);
void arm_write_dacr(uint32_t val);
void arm_invalidate_tlb(void);
#if defined(__cplusplus)
}
#endif
#endif
+122
View File
@@ -0,0 +1,122 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARM_CORES_H
#define __ARM_CORES_H
/*
* make the gcc built in define a little easier to deal with
* to decide what core it is generating code for
*
* ARM_ARCH_LEVEL gets assigned a numeric value of the general family
*
* ARM_ARCH_* gets defined for each feature recursively
*/
#if defined(__ARM_ARCH_7M__)
#define ARM_ARCH_7M 1
#endif
#if defined(__ARM_ARCH_7R__)
#define ARM_ARCH_7R 1
#endif
#if defined(__ARM_ARCH_7A__) || defined(ARM_ARCH_7R)
#define ARM_ARCH_7A 1
#endif
#if defined(__ARM_ARCH_7__) || defined(ARM_ARCH_7A) || defined(ARM_ARCH_7M)
#define ARM_ARCH_7 1
#ifndef ARM_ARCH_LEVEL
#define ARM_ARCH_LEVEL 7
#endif
#endif
#if defined(__ARM_ARCH_6M__)
#define ARM_ARCH_6M 1
#endif
#if defined(__ARM_ARCH_6T2__) || defined(ARM_ARCH_7)
#define ARM_ARCH_6T2 1
#endif
#if defined(__ARM_ARCH_6ZK__)
#define ARM_ARCH_6ZK 1
#endif
#if defined(__ARM_ARCH_6Z__) || defined(ARM_ARCH_6ZK)
#define ARM_ARCH_6Z 1
#endif
#if defined(__ARM_ARCH_6K__) || defined(ARM_ARCH_6ZK) || defined(ARM_ARCH_7)
#define ARM_ARCH_6K 1
#endif
#if defined(__ARM_ARCH_6J__)
#define ARM_ARCH_6J 1
#endif
#if defined(__ARM_ARCH_6__) || defined(ARM_ARCH_6J) || defined(ARM_ARCH_6K) || defined(ARM_ARCH_6Z) || defined(ARM_ARCH_6T2) || defined(ARM_ARCH_6M)
#define ARM_ARCH_6 1
#ifndef ARM_ARCH_LEVEL
#define ARM_ARCH_LEVEL 6
#endif
#endif
#if defined(__ARM_ARCH_5TEJ__)
#define ARM_ARCH_5TEJ 1
#endif
#if defined(__ARM_ARCH_5TE__) || defined(ARM_ARCH_5TEJ) || defined(ARM_ARCH_6)
#define ARM_ARCH_5TE 1
#endif
#if defined(__ARM_ARCH_5E__) || defined(ARM_ARCH_5TE)
#define ARM_ARCH_5E 1
#endif
#if defined(__ARM_ARCH_5T__) || defined(ARM_ARCH_5TE)
#define ARM_ARCH_5T 1
#endif
#if defined(__ARM_ARCH_5__) || defined(ARM_ARCH_5E) || defined(ARM_ARCH_5T)
#define ARM_ARCH_5 1
#ifndef ARM_ARCH_LEVEL
#define ARM_ARCH_LEVEL 5
#endif
#endif
#if defined(__ARM_ARCH_4T__) || defined(ARM_ARCH_5T)
#define ARM_ARCH_4T 1
#endif
#if defined(__ARM_ARCH_4__) || defined(ARM_ARCH_4T) || defined(ARM_ARCH_5)
#define ARM_ARCH_4 1
#ifndef ARM_ARCH_LEVEL
#define ARM_ARCH_LEVEL 4
#endif
#endif
#if 0
/* test */
#if ARM_ARCH_LEVEL >= 7
#warning ARM_ARCH_LEVEL >= 7
#endif
#if ARM_ARCH_LEVEL >= 6
#warning ARM_ARCH_LEVEL >= 6
#endif
#if ARM_ARCH_LEVEL >= 5
#warning ARM_ARCH_LEVEL >= 5
#endif
#if ARM_ARCH_LEVEL >= 4
#warning ARM_ARCH_LEVEL >= 4
#endif
#endif
#endif
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2008 Brian Swetland
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_ARM_DCC_H
#define __ARCH_ARM_DCC_H
/* returns < 0 if no data available */
int dcc_getc(void);
/* returns < 0 if output register was already full */
int dcc_putc(unsigned c);
#endif
+63
View File
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_ARM_MMU_H
#define __ARCH_ARM_MMU_H
#include <sys/types.h>
#if defined(__cplusplus)
extern "C" {
#endif
void arm_mmu_init(void);
#if defined(ARM_ISA_ARMV6) | defined(ARM_ISA_ARMV7)
/* C, B and TEX[2:0] encodings without TEX remap */
/* TEX | CB */
#define MMU_MEMORY_TYPE_STRONGLY_ORDERED ((0x0 << 12) | (0x0 << 2))
#define MMU_MEMORY_TYPE_DEVICE_SHARED ((0x0 << 12) | (0x1 << 2))
#define MMU_MEMORY_TYPE_DEVICE_NON_SHARED ((0x2 << 12) | (0x0 << 2))
#define MMU_MEMORY_TYPE_NORMAL ((0x1 << 12) | (0x0 << 2))
#define MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH ((0x0 << 12) | (0x2 << 2))
#define MMU_MEMORY_TYPE_NORMAL_WRITE_BACK_NO_ALLOCATE ((0x0 << 12) | (0x3 << 2))
#define MMU_MEMORY_TYPE_NORMAL_WRITE_BACK_ALLOCATE ((0x1 << 12) | (0x3 << 2))
#define MMU_MEMORY_AP_NO_ACCESS (0x0 << 10)
#define MMU_MEMORY_AP_READ_ONLY (0x7 << 10)
#define MMU_MEMORY_AP_READ_WRITE (0x3 << 10)
#else
#error "MMU implementation needs to be updated for this ARM architecture"
#endif
void arm_mmu_map_section(addr_t paddr, addr_t vaddr, uint flags);
#if defined(__cplusplus)
}
#endif
#endif
+48
View File
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_ARM_OPS_H
#define __ARHC_ARM_OPS_H
#if 0
#include <compiler.h>
#ifndef ASSEMBLY
#if ARM_ISA_ARMV7 || ARM_ISA_ARMV6
// override of some routines
__GNU_INLINE __ALWAYS_INLINE extern inline void arch_enable_ints(void)
{
__asm__("cpsie i");
}
__GNU_INLINE __ALWAYS_INLINE extern inline void arch_disable_ints(void)
{
__asm__("cpsid i");
}
#endif
#endif
#endif
#endif
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_CPU_H
#define __ARCH_CPU_H
/* arm specific stuff */
#define PAGE_SIZE 4096
#if defined(ARM_CPU_ARM1136)
#define CACHE_LINE 32
#elif defined(ARM_CPU_CORE_A5)
#define CACHE_LINE 32
#elif defined(ARM_CPU_CORE_SCORPION)
#define CACHE_LINE 32
#elif defined(ARM_CPU_CORE_KRAIT)
#define CACHE_LINE 64
#else
#error unknown cpu
#endif
#endif
+97
View File
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <sys/types.h>
#include <compiler.h>
#include <arch.h>
#include <arch/arm.h>
#include <arch/arm/mmu.h>
#if ARM_WITH_MMU
#define MB (1024*1024)
/* the location of the table may be brought in from outside */
#if WITH_EXTERNAL_TRANSLATION_TABLE
#if !defined(MMU_TRANSLATION_TABLE_ADDR)
#error must set MMU_TRANSLATION_TABLE_ADDR in the make configuration
#endif
static uint32_t *tt = (void *)MMU_TRANSLATION_TABLE_ADDR;
#else
/* the main translation table */
static uint32_t tt[4096] __ALIGNED(16384);
#endif
void arm_mmu_map_section(addr_t paddr, addr_t vaddr, uint flags)
{
int index;
/* Get the index into the translation table */
index = vaddr / MB;
/* Set the entry value:
* (2<<0): Section entry
* (0<<5): Domain = 0
* flags: TEX, CB and AP bit settings provided by the caller.
*/
tt[index] = (paddr & ~(MB-1)) | (0<<5) | (2<<0) | flags;
arm_invalidate_tlb();
}
void arm_mmu_init(void)
{
int i;
/* set some mmu specific control bits:
* access flag disabled, TEX remap disabled, mmu disabled
*/
arm_write_cr1(arm_read_cr1() & ~((1<<29)|(1<<28)|(1<<0)));
/* set up an identity-mapped translation table with
* strongly ordered memory type and read/write access.
*/
for (i=0; i < 4096; i++) {
arm_mmu_map_section(i * MB,
i * MB,
MMU_MEMORY_TYPE_STRONGLY_ORDERED |
MMU_MEMORY_AP_READ_WRITE);
}
/* set up the translation table base */
arm_write_ttbr((uint32_t)tt);
/* set up the domain access register */
arm_write_dacr(0x00000001);
/* turn on the mmu */
arm_write_cr1(arm_read_cr1() | 0x1);
}
void arch_disable_mmu(void)
{
arm_write_cr1(arm_read_cr1() & ~(1<<0));
}
#endif // ARM_WITH_MMU
+235
View File
@@ -0,0 +1,235 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
.text
/* void arch_enable_ints(void); */
FUNCTION(arch_enable_ints)
mrs r0, cpsr
bic r0, r0, #(1<<7) /* clear the I bit */
msr cpsr_c, r0
bx lr
/* void arch_disable_ints(void); */
FUNCTION(arch_disable_ints)
mrs r0, cpsr
orr r0, r0, #(1<<7)
msr cpsr_c, r0
bx lr
/* int atomic_swap(int *ptr, int val); */
FUNCTION(atomic_swap)
swp r0, r2, [r1]
bx lr
/* int atomic_add(int *ptr, int val); */
FUNCTION(atomic_add)
#if ARM_ISA_ARMV6 || ARM_ISA_ARMV7
/* use load/store exclusive */
.L_loop_add:
ldrex r12, [r0]
add r2, r12, r1
strex r3, r2, [r0]
cmp r3, #0
bne .L_loop_add
/* save old value */
mov r0, r12
bx lr
#else
/* disable interrupts, do the add, and reenable */
mrs r2, cpsr
mov r12, r2
orr r2, r2, #(3<<6)
msr cpsr_c, r2
/* ints disabled, old cpsr state in r12 */
/* do the add, leave the previous value in r0 */
mov r3, r0
ldr r0, [r3]
add r2, r0, r1
str r2, [r3]
/* restore interrupts and exit */
msr cpsr_c, r12
bx lr
#endif
/* int atomic_and(int *ptr, int val); */
FUNCTION(atomic_and)
#if ARM_ISA_ARMV6 || ARM_ISA_ARMV7
/* use load/store exclusive */
.L_loop_and:
ldrex r12, [r0]
and r2, r12, r1
strex r3, r2, [r0]
cmp r3, #0
bne .L_loop_and
/* save old value */
mov r0, r12
bx lr
#else
/* disable interrupts, do the and, and reenable */
mrs r2, cpsr
mov r12, r2
orr r2, r2, #(3<<6)
msr cpsr_c, r2
/* ints disabled, old cpsr state in r12 */
/* do the and, leave the previous value in r0 */
mov r3, r0
ldr r0, [r3]
and r2, r0, r1
str r2, [r3]
/* restore interrupts and exit */
msr cpsr_c, r12
bx lr
#endif
/* int atomic_or(int *ptr, int val); */
FUNCTION(atomic_or)
#if ARM_ISA_ARMV6 || ARM_ISA_ARMV7
/* use load/store exclusive */
.L_loop_or:
ldrex r12, [r0]
orr r2, r12, r1
strex r3, r2, [r0]
cmp r3, #0
bne .L_loop_or
/* save old value */
mov r0, r12
bx lr
#else
/* disable interrupts, do the or, and reenable */
mrs r2, cpsr
mov r12, r2
orr r2, r2, #(3<<6)
msr cpsr_c, r2
/* ints disabled, old cpsr state in r12 */
/* do the or, leave the previous value in r0 */
mov r3, r0
ldr r0, [r3]
orr r2, r0, r1
str r2, [r3]
/* restore interrupts and exit */
msr cpsr_c, r12
bx lr
#endif
/* void arch_idle(); */
FUNCTION(arch_idle)
#if ARM_CPU_CORTEX_A8
.word 0xe320f003 /* wfi */
#elif PLATFORM_MSM7K
/* TODO: safely handle wfi */
#elif ARM_CPU_ARM1136 || ARM_CPU_ARM926
mov r0, #0
mcr p15, 0, r0, c7, c0, #4
#elif ARM_CPU_ARM7
/* nothing to do here */
#else
#error unknown cpu
#endif
bx lr
/* uint32_t arm_read_cr1(void) */
FUNCTION(arm_read_cr1)
mrc p15, 0, r0, c1, c0, 0
bx lr
/* void arm_write_cr1(uint32_t val) */
FUNCTION(arm_write_cr1)
mcr p15, 0, r0, c1, c0, 0
bx lr
/* uint32_t arm_read_cr1_aux(void) */
FUNCTION(arm_read_cr1_aux)
mrc p15, 0, r0, c1, c0, 1
bx lr
/* void arm_write_cr1_aux(uint32_t val) */
FUNCTION(arm_write_cr1_aux)
mcr p15, 0, r0, c1, c0, 1
bx lr
/* void arm_write_ttbr(uint32_t val) */
FUNCTION(arm_write_ttbr)
mcr p15, 0, r0, c2, c0, 0
bx lr
/* void arm_write_dacr(uint32_t val) */
FUNCTION(arm_write_dacr)
mcr p15, 0, r0, c3, c0, 0
bx lr
/* void arm_invalidate_tlb(void) */
FUNCTION(arm_invalidate_tlb)
mov r0, #0
mcr p15, 0, r0, c8, c7, 0
bx lr
/* void arch_switch_stacks_and_call(addr_t call, addr_t stack) */
FUNCTION(arch_switch_stacks_and_call)
mov sp, r1
bx r0
/*void dmb(void) */
FUNCTION(dmb)
#if ARM_CPU_CORTEX_A8
dmb sy
#elif ARM_CPU_ARM1136
mov r0, #0
mcr p15, 0, r0, c7, c10, 5
#endif
bx lr
/*void dsb(void) */
FUNCTION(dsb)
#if ARM_CPU_CORTEX_A8
dsb sy
#elif ARM_CPU_ARM1136
mov r0, #0
mcr p15, 0, r0, c7, c10, 4
#endif
bx lr
/* uint32_t arm_read_cycle_count(void); */
FUNCTION(arm_read_cycle_count)
/* uint32_t arch_cycle_count(void); */
FUNCTION(arch_cycle_count)
#if ARM_CPU_CORTEX_A8
mrc p15, 0, r0, c9, c13, 0
#else
mov r0, #0
#endif
bx lr
+154
View File
@@ -0,0 +1,154 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
# can override this in local.mk
ENABLE_THUMB?=true
DEFINES += \
ARM_CPU_$(ARM_CPU)=1
# do set some options based on the cpu core
HANDLED_CORE := false
ifeq ($(ARM_CPU),cortex-a8)
DEFINES += \
ARM_WITH_CP15=1 \
ARM_WITH_MMU=1 \
ARM_ISA_ARMv7=1 \
ARM_WITH_VFP=1 \
ARM_WITH_NEON=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_THUMB2=1 \
ARM_WITH_CACHE=1 \
ARM_WITH_L2=1
CFLAGS += -mcpu=$(ARM_CPU)
#CFLAGS += -mcpu=arm1136jf-s # compiler doesn't understand cortex yet
HANDLED_CORE := true
#CFLAGS += -mfpu=vfp -mfloat-abi=softfp
endif
ifeq ($(ARM_CPU),arm1136j-s)
DEFINES += \
ARM_WITH_CP15=1 \
ARM_WITH_MMU=1 \
ARM_ISA_ARMv6=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_CACHE=1 \
ARM_CPU_ARM1136=1
CFLAGS += -mcpu=$(ARM_CPU)
HANDLED_CORE := true
endif
ifeq ($(ARM_CPU),arm1176jzf-s)
DEFINES += \
ARM_WITH_CP15=1 \
ARM_WITH_MMU=1 \
ARM_ISA_ARMv6=1 \
ARM_WITH_VFP=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_CACHE=1 \
ARM_CPU_ARM1136=1
CFLAGS += -mcpu=$(ARM_CPU)
HANDLED_CORE := true
endif
ifeq ($(ARM_CPU),arm926ej-s)
DEFINES += \
ARM_WITH_CP15=1 \
ARM_WITH_MMU=1 \
ARM_ISA_ARMv5E=1 \
ARM_WITH_THUMB=1 \
ARM_WITH_CACHE=1 \
ARM_CPU_ARM9=1 \
ARM_CPU_ARM926=1
CFLAGS += -mcpu=$(ARM_CPU)
HANDLED_CORE := true
endif
ifeq ($(ARM_CPU),arm7tdmi)
DEFINES += \
ARM_ISA_ARMv4=1 \
ARM_WITH_THUMB=1 \
ARM_CPU_ARM7=1
CFLAGS += -mcpu=$(ARM_CPU)
HANDLED_CORE := true
endif
ifneq ($(HANDLED_CORE),true)
$(warning $(LOCAL_DIR)/rules.mk doesnt have logic for arm core $(ARM_CPU))
$(warning this is likely to be broken)
endif
THUMBCFLAGS :=
THUMBINTERWORK :=
ifeq ($(ENABLE_THUMB),true)
THUMBCFLAGS := -mthumb -D__thumb__
THUMBINTERWORK := -mthumb-interwork
endif
INCLUDES += \
-I$(LOCAL_DIR)/include
BOOTOBJS += \
$(LOCAL_DIR)/crt0.o
OBJS += \
$(LOCAL_DIR)/arch.Ao \
$(LOCAL_DIR)/asm.o \
$(LOCAL_DIR)/cache.o \
$(LOCAL_DIR)/cache-ops.o \
$(LOCAL_DIR)/ops.o \
$(LOCAL_DIR)/exceptions.o \
$(LOCAL_DIR)/faults.o \
$(LOCAL_DIR)/mmu.o \
$(LOCAL_DIR)/thread.o \
$(LOCAL_DIR)/dcc.o
# set the default toolchain to arm eabi and set a #define
TOOLCHAIN_PREFIX ?= arm-eabi-
ifeq ($(TOOLCHAIN_PREFIX),arm-none-linux-gnueabi-)
# XXX test for EABI better than this
# eabi compilers dont need this
THUMBINTERWORK:=
endif
CFLAGS += $(THUMBINTERWORK)
# make sure some bits were set up
MEMVARS_SET := 0
ifneq ($(MEMBASE),)
MEMVARS_SET := 1
endif
ifneq ($(MEMSIZE),)
MEMVARS_SET := 1
endif
ifeq ($(MEMVARS_SET),0)
$(error missing MEMBASE or MEMSIZE variable, please set in target rules.mk)
endif
LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(CFLAGS) $(THUMBCFLAGS) -print-libgcc-file-name)
#$(info LIBGCC = $(LIBGCC))
# potentially generated files that should be cleaned out with clean make rule
GENERATED += \
$(BUILDDIR)/system-onesegment.ld \
$(BUILDDIR)/system-twosegment.ld
# rules for generating the linker scripts
$(BUILDDIR)/trustzone-test-system-onesegment.ld: $(LOCAL_DIR)/trustzone-test-system-onesegment.ld
@echo generating $@
@$(MKDIR)
$(NOECHO)sed "s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/;s/%ROMLITE_PREFLASHED_DATA%/$(ROMLITE_PREFLASHED_DATA)/" < $< > $@
$(BUILDDIR)/trustzone-system-onesegment.ld: $(LOCAL_DIR)/trustzone-system-onesegment.ld
@echo generating $@
@$(MKDIR)
$(NOECHO)sed "s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@
$(BUILDDIR)/system-onesegment.ld: $(LOCAL_DIR)/system-onesegment.ld
@echo generating $@
@$(MKDIR)
$(NOECHO)sed "s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@
$(BUILDDIR)/system-twosegment.ld: $(LOCAL_DIR)/system-twosegment.ld
@echo generating $@
@$(MKDIR)
$(NOECHO)sed "s/%ROMBASE%/$(ROMBASE)/;s/%MEMBASE%/$(MEMBASE)/;s/%MEMSIZE%/$(MEMSIZE)/" < $< > $@
+83
View File
@@ -0,0 +1,83 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = %MEMBASE%;
/* text/read-only data */
.text.boot : { *(.text.boot) }
.text : { *(.text .text.* .glue_7* .gnu.linkonce.t.*) } =0x9090
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
.rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
.rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
.rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) } =0x9090
.plt : { *(.plt) }
.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(4);
__commands_start = .;
KEEP (*(.commands))
__commands_end = .;
. = ALIGN(4);
__apps_start = .;
KEEP (*(.apps))
__apps_end = .;
. = ALIGN(4);
__rodata_end = . ;
}
/* writable data */
__data_start_rom = .; /* in one segment binaries, the rom data address is on top of the ram data address */
__data_start = .;
.data : SUBALIGN(4) { *(.data .data.* .gnu.linkonce.d.*) }
__ctor_list = .;
.ctors : { *(.ctors) }
__ctor_end = .;
__dtor_list = .;
.dtors : { *(.dtors) }
__dtor_end = .;
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) }
__data_end = .;
/* unintialized data (in same segment as writable data) */
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss .bss.*) }
. = ALIGN(4);
_end = .;
. = %MEMBASE% + %MEMSIZE%;
_end_of_ram = .;
/* Strip unnecessary stuff */
/DISCARD/ : { *(.comment .note .eh_frame) }
}
+86
View File
@@ -0,0 +1,86 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
. = %ROMBASE%;
/* text/read-only data */
.text.boot : { *(.text.boot) }
.text : { *(.text .text.* .glue_7* .gnu.linkonce.t.*) } =0x9090
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
.rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
.rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
.rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) } =0x9090
.plt : { *(.plt) }
.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(4);
__commands_start = .;
KEEP (*(.commands))
__commands_end = .;
. = ALIGN(4);
__apps_start = .;
KEEP (*(.apps))
__apps_end = .;
. = ALIGN(4);
__rodata_end = . ;
}
/* writable data */
__data_start_rom = .;
. = %MEMBASE%;
__data_start = .;
.data :
AT ( ADDR (.rodata) + SIZEOF (.rodata) )
{ *(.data .data.* .gnu.linkonce.d.*) }
__ctor_list = .;
.ctors : { *(.ctors) }
__ctor_end = .;
__dtor_list = .;
.dtors : { *(.dtors) }
__dtor_end = .;
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) }
__data_end = .;
/* unintialized data (in same segment as writable data) */
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss .bss.*) }
. = ALIGN(4);
_end = . ;
. = %MEMBASE% + %MEMSIZE%;
_end_of_ram = . ;
/* Strip unnecessary stuff */
/DISCARD/ : { *(.comment .note .eh_frame) }
}
+88
View File
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <debug.h>
#include <kernel/thread.h>
#include <arch/arm.h>
struct context_switch_frame {
vaddr_t r4;
vaddr_t r5;
vaddr_t r6;
vaddr_t r7;
vaddr_t r8;
vaddr_t r9;
vaddr_t r10;
vaddr_t r11;
vaddr_t lr;
vaddr_t usp;
vaddr_t ulr;
};
extern void arm_context_switch(addr_t *old_sp, addr_t new_sp);
static void initial_thread_func(void) __NO_RETURN;
static void initial_thread_func(void)
{
int ret;
// dprintf("initial_thread_func: thread %p calling %p with arg %p\n", current_thread, current_thread->entry, current_thread->arg);
// dump_thread(current_thread);
/* exit the implicit critical section we're within */
exit_critical_section();
ret = current_thread->entry(current_thread->arg);
// dprintf("initial_thread_func: thread %p exiting with %d\n", current_thread, ret);
thread_exit(ret);
}
void arch_thread_initialize(thread_t *t)
{
// create a default stack frame on the stack
vaddr_t stack_top = (vaddr_t)t->stack + t->stack_size;
// make sure the top of the stack is 8 byte aligned for EABI compliance
stack_top = ROUNDDOWN(stack_top, 8);
struct context_switch_frame *frame = (struct context_switch_frame *)(stack_top);
frame--;
// fill it in
memset(frame, 0, sizeof(*frame));
frame->lr = (vaddr_t)&initial_thread_func;
// set the stack pointer
t->arch.sp = (vaddr_t)frame;
}
void arch_context_switch(thread_t *oldthread, thread_t *newthread)
{
// dprintf("arch_context_switch: old %p (%s), new %p (%s)\n", oldthread, oldthread->name, newthread, newthread->name);
arm_context_switch(&oldthread->arch.sp, newthread->arch.sp);
}
+92
View File
@@ -0,0 +1,92 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
/*Added TRUSTZONE at 0x0. Moving rest of APPSBL to %MEMBASE% */
. = 0x0;
.tzbsp 0x0 : {*tzbsp_bin.o(.data)}
. = %MEMBASE%;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
.rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
.rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
.rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/*Moving harcoded addresses by a displacement of %MEMBASE% */
.init : { *(.init) } = %MEMBASE% + 0x9090
.plt : { *(.plt) }
/* text/read-only data */
/*Moving harcoded addresses by a displacement of %MEMBASE% */
.text : { *(.text .text.* .glue_7* .gnu.linkonce.t.*) } = %MEMBASE% + 0x9090
.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(4);
__commands_start = .;
KEEP (*(.commands))
__commands_end = .;
. = ALIGN(4);
__apps_start = .;
KEEP (*(.apps))
__apps_end = .;
. = ALIGN(4);
__rodata_end = . ;
}
/* writable data */
__data_start_rom = .; /* in one segment binaries, the rom data address is on top of the ram data address */
__data_start = .;
.data : SUBALIGN(4) { *(.data .data.* .gnu.linkonce.d.*) }
__ctor_list = .;
.ctors : { *(.ctors) }
__ctor_end = .;
__dtor_list = .;
.dtors : { *(.dtors) }
__dtor_end = .;
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) }
__data_end = .;
/* unintialized data (in same segment as writable data) */
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss .bss.*) }
. = ALIGN(4);
_end = .;
. = %MEMBASE% + %MEMSIZE%;
_end_of_ram = .;
/* Strip unnecessary stuff */
/DISCARD/ : { *(.comment .note .eh_frame) }
}
@@ -0,0 +1,93 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
/*Added TRUSTZONE at 0x0. Moving rest of APPSBL to %MEMBASE% */
. = 0x0;
.tzbsp 0x0 : {*tzbsp_bin.o(.data)}
.romlite 0xBF000 : {*romlite_toc_and_data.o(.data.rom_lite_preflashed_data)}
. = %MEMBASE%;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) }
.rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) }
.rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) }
.rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) }
.rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) }
.rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/*Moving harcoded addresses by a displacement of %MEMBASE% */
.init : { *(.init) } = %MEMBASE% + 0x9090
.plt : { *(.plt) }
/* text/read-only data */
/*Moving harcoded addresses by a displacement of %MEMBASE% */
.text : { *(.text .text.* .glue_7* .gnu.linkonce.t.*) } = %MEMBASE% + 0x9090
.rodata : {
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN(4);
__commands_start = .;
KEEP (*(.commands))
__commands_end = .;
. = ALIGN(4);
__apps_start = .;
KEEP (*(.apps))
__apps_end = .;
. = ALIGN(4);
__rodata_end = . ;
}
/* writable data */
__data_start_rom = .; /* in one segment binaries, the rom data address is on top of the ram data address */
__data_start = .;
.data : SUBALIGN(4) { *(.data .data.* .gnu.linkonce.d.*) }
__ctor_list = .;
.ctors : { *(.ctors) }
__ctor_end = .;
__dtor_list = .;
.dtors : { *(.dtors) }
__dtor_end = .;
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) }
__data_end = .;
/* unintialized data (in same segment as writable data) */
. = ALIGN(4);
__bss_start = .;
.bss : { *(.bss .bss.*) }
. = ALIGN(4);
_end = .;
. = %MEMBASE% + %MEMSIZE%;
_end_of_ram = .;
/* Strip unnecessary stuff */
/DISCARD/ : { *(.comment .note .eh_frame) }
}
+70
View File
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <arch.h>
#include <arch/ops.h>
#include <arch/x86.h>
#include <arch/x86/mmu.h>
#include <arch/x86/descriptor.h>
#include <platform.h>
#include <sys/types.h>
#include <string.h>
static tss_t system_tss;
void arch_early_init(void)
{
x86_mmu_init();
platform_init_mmu_mappings();
/* enable caches here for now */
clear_in_cr0(X86_CR0_NW | X86_CR0_CD);
memset(&system_tss, 0, sizeof(tss_t));
system_tss.esp0 = 0;
system_tss.ss0 = DATA_SELECTOR;
system_tss.ss1 = 0;
system_tss.ss2 = 0;
system_tss.eflags = 0x00003002;
system_tss.bitmap = offsetof(tss_t, tss_bitmap);
system_tss.trace = 1; // trap on hardware task switch
set_global_desc(TSS_SELECTOR, &system_tss, sizeof(tss_t), 1, 0, 0, SEG_TYPE_TSS, 0, 0);
x86_ltr(TSS_SELECTOR);
}
void arch_init(void)
{
}
uint32_t arch_cycle_count(void)
{
uint32_t timestamp;
rdtscl(timestamp);
return timestamp;
}
+24
View File
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
#include <arch/ops.h>
#include <arch/defines.h>
.text
/* stubs */
FUNCTION(arch_disable_cache)
ret
FUNCTION(arch_enable_cache)
ret
FUNCTION(arch_clean_cache_range)
ret
FUNCTION(arch_clean_invalidate_cache_range)
ret
+22
View File
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+16
View File
@@ -0,0 +1,16 @@
$(BUILDDIR)/%.o: %.c $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) --std=c99 $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.o: %.cpp $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
$(BUILDDIR)/%.o: %.S $(SRCDEPS)
@$(MKDIR)
@echo compiling $<
$(NOECHO)$(CC) $(CFLAGS) $(ASMFLAGS) $(INCLUDES) -c $< -MD -MT $@ -MF $(@:%o=%d) -o $@
+315
View File
@@ -0,0 +1,315 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* The magic number for the Multiboot header. */
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
/* The flags for the Multiboot header. */
#if defined(__ELF__) && 0
#define MULTIBOOT_HEADER_FLAGS 0x00000002
#else
#define MULTIBOOT_HEADER_FLAGS 0x00010002
#endif
/* The magic number passed by a Multiboot-compliant boot loader. */
#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002
#define NUM_INT 0x31
#define NUM_EXC 0x14
.text
.global _start
_start:
jmp real_start
.align 4
multiboot_header:
/* magic */
.int MULTIBOOT_HEADER_MAGIC
/* flags */
.int MULTIBOOT_HEADER_FLAGS
/* checksum */
.int -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
#if !defined(__ELF__) || 1
/* header_addr */
.int multiboot_header
/* load_addr */
.int _start
/* load_end_addr */
.int __bss_start
/* bss_end_addr */
.int __bss_end
/* entry_addr */
.int real_start
#endif
real_start:
cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
jne 0f
movl %ebx, (_multiboot_info)
0:
/* setup isr stub descriptors in the idt */
movl $_isr, %esi
movl $_idt, %edi
movl $NUM_INT, %ecx
.Lloop:
movl %esi, %ebx
movw %bx, (%edi) /* low word in IDT(n).low */
shrl $16, %ebx
movw %bx, 6(%edi) /* high word in IDT(n).high */
addl $isr_stub_len, %esi/* index the next ISR stub */
addl $8, %edi /* index the next IDT entry */
loop .Lloop
lidt _idtr
xorl %eax, %eax
movl %eax, %cr3
lgdt _gdtr
movw $datasel, %ax
movw %ax, %ds
movw %ax, %es
movw %ax, %fs
movw %ax, %ss
movw %ax, %gs
movw %ax, %ss
movl $_kstack, %esp
/* zero the bss section */
movl $__bss_start, %edi /* starting address of the bss */
movl $__bss_end, %ecx /* find the length of the bss in bytes */
subl %edi, %ecx
shrl $2, %ecx /* convert to 32 bit words, since the bss is aligned anyway */
2:
movl $0, (%edi)
addl $4, %edi
loop 2b
/* call the main module */
call kmain
0: /* just sit around waiting for interrupts */
hlt /* interrupts will unhalt the processor */
pause
jmp 0b /* so jump back to halt to conserve power */
/* interrupt service routine stubs */
_isr:
.set i, 0
.rept NUM_INT
.set isr_stub_start, .
.if i == 8 || (i >= 10 && i <= 14) || i == 17
nop /* error code pushed by exception */
nop /* 2 nops are the same length as push byte */
pushl $i /* interrupt number */
jmp interrupt_common
.else
pushl $0 /* fill in error code in iframe */
pushl $i /* interrupt number */
jmp interrupt_common
.endif
/* figure out the length of a single isr stub (usually 6 or 9 bytes) */
.set isr_stub_len, . - isr_stub_start
.set i, i + 1
.endr
/* annoying, but force AS to use the same (longer) encoding of jmp for all of the stubs */
.fill 256
interrupt_common:
pushl %gs /* save segment registers */
pushl %fs
pushl %es
pushl %ds
pusha /* save general purpose registers */
movl $datasel, %eax /* put known good value in segment registers */
movl %eax, %gs
movl %eax, %fs
movl %eax, %es
movl %eax, %ds
movl %esp, %eax /* store stack switch pivot. push esp has errata on some cpus, so use mov/push */
pushl %eax
movl %esp, %eax /* store pointer to iframe, using same method */
pushl %eax
incl critical_section_count
call platform_irq
cmpl $0,%eax
je 0f
call thread_preempt
0:
decl critical_section_count
popl %eax /* drop pointer to iframe */
popl %eax /* restore task_esp, stack switch can occur here if task_esp is modified */
movl %eax, %esp
popa /* restore general purpose registers */
popl %ds /* restore segment registers */
popl %es
popl %fs
popl %gs
addl $8, %esp /* drop exception number and error code */
iret
.data
.align 4
/* define the heap end as read-write data containing the default end of the
* heap. dynamic memory length discovery can update this value during init.
* other archs can define this statically based on the memory layout of the
* platform.
*/
.global _heap_end
_heap_end:
.int 4096*1024 /* default to 4MB total */
.global _multiboot_info
_multiboot_info:
.int 0
.global _gdtr
_gdtr:
.short _gdt_end - _gdt - 1
.int _gdt
.global _gdt
_gdt:
.int 0
.int 0
/* ring 0 descriptors */
.set codesel, . - _gdt
_code_gde:
.short 0xffff /* limit 15:00 */
.short 0x0000 /* base 15:00 */
.byte 0x00 /* base 23:16 */
.byte 0b10011010 /* P(1) DPL(00) S(1) 1 C(0) R(1) A(0) */
.byte 0b11001111 /* G(1) D(1) 0 0 limit 19:16 */
.byte 0x0 /* base 31:24 */
.set datasel, . - _gdt
_data_gde:
.short 0xffff /* limit 15:00 */
.short 0x0000 /* base 15:00 */
.byte 0x00 /* base 23:16 */
.byte 0b10010010 /* P(1) DPL(00) S(1) 0 E(0) W(1) A(0) */
.byte 0b11001111 /* G(1) B(1) 0 0 limit 19:16 */
.byte 0x0 /* base 31:24 */
.set videosel, . - _gdt
_video_gde:
.short 0xffff /* limit 15:00 */
.short 0x8000 /* base 15:00 */
.byte 0x0b /* base 23:16 */
.byte 0b10010010 /* P(1) DPL(00) S(1) 0 E(0) W(1) A(0) */
.byte 0b11001111 /* G(1) B(1) 0 0 limit 19:16 */
.byte 0x0 /* base 31:24 */
.if 1
/* ring 3 descriptors */
.set user_codesel, . - _gdt
_user_code_gde:
.short 0xffff /* limit 15:00 */
.short 0x0000 /* base 15:00 */
.byte 0x00 /* base 23:16 */
.byte 0b11111010 /* P(1) DPL(11) S(1) 1 C(0) R(1) A(0) */
.byte 0b11001111 /* G(1) D(1) 0 0 limit 19:16 */
.byte 0x0 /* base 31:24 */
.set user_datasel, . - _gdt
_user_data_gde:
.short 0xffff /* limit 15:00 */
.short 0x0000 /* base 15:00 */
.byte 0x00 /* base 23:16 */
.byte 0b11110010 /* P(1) DPL(11) S(1) 0 E(0) W(1) A(0) */
.byte 0b11001111 /* G(1) B(1) 0 0 limit 19:16 */
.byte 0x0 /* base 31:24 */
.endif
/* TSS descriptor */
.if 1
.set tsssel, . - _gdt
_tss_gde:
.short 0 /* limit 15:00 */
.short 0 /* base 15:00 */
.byte 0 /* base 23:16 */
.byte 0xe9 /* P(1) DPL(11) 0 10 B(0) 1 */
.byte 0x00 /* G(0) 0 0 AVL(0) limit 19:16 */
.short 0 /* base 31:24 */
.endif
.global _gdt_end
_gdt_end:
.global _idtr
_idtr:
.short _idt_end - _idt - 1 /* IDT limit */
.int _idt
/* interrupt descriptor table (IDT) */
.global _idt
_idt:
.set i, 0
.rept NUM_INT-1
.short 0 /* low 16 bits of ISR offset (_isr#i & 0FFFFh) */
.short codesel /* selector */
.byte 0
.byte 0x8e /* present, ring 0, 32-bit interrupt gate */
.short 0 /* high 16 bits of ISR offset (_isr#i / 65536) */
.set i, i + 1
.endr
/* syscall int (ring 3) */
_idt30:
.short 0 /* low 16 bits of ISR offset (_isr#i & 0FFFFh) */
.short codesel /* selector */
.byte 0
.byte 0xee /* present, ring 3, 32-bit interrupt gate */
.short 0 /* high 16 bits of ISR offset (_isr#i / 65536) */
.global _idt_end
_idt_end:
.bss
.align 4096
.global _kstack
.fill 4096
_kstack:
+68
View File
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <compiler.h>
#include <arch/x86/descriptor.h>
/* not the best way to do this, but easy for now */
typedef struct {
uint16_t limit_15_0;
uint16_t base_15_0;
uint8_t base_23_16;
uint8_t type : 4;
uint8_t s : 1;
uint8_t dpl : 2;
uint8_t p : 1;
uint8_t limit_19_16 : 4;
uint8_t avl : 1;
uint8_t reserved_0 : 1;
uint8_t d_b : 1;
uint8_t g : 1;
uint8_t base_31_24;
} __PACKED seg_desc_t;
extern seg_desc_t _gdt[];
void set_global_desc(seg_sel_t sel, void *base, uint32_t limit,
uint8_t present, uint8_t ring, uint8_t sys, uint8_t type, uint8_t gran, uint8_t bits)
{
// convert selector into index
uint16_t index = sel >> 3;
_gdt[index].limit_15_0 = limit & 0x0000ffff;
_gdt[index].limit_19_16 = (limit & 0x000f0000) >> 16;
_gdt[index].base_15_0 = ((uint32_t) base) & 0x0000ffff;
_gdt[index].base_23_16 = (((uint32_t) base) & 0x00ff0000) >> 16;
_gdt[index].base_31_24 = ((uint32_t) base) >> 24;
_gdt[index].type = type & 0x0f; // segment type
_gdt[index].p = present != 0; // present
_gdt[index].dpl = ring & 0x03; // descriptor privilege level
_gdt[index].g = gran != 0; // granularity
_gdt[index].s = sys != 0; // system / non-system
_gdt[index].d_b = bits != 0; // 16 / 32 bit
}
+77
View File
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <arch/x86.h>
#include <kernel/thread.h>
static void dump_fault_frame(struct x86_iframe *frame)
{
dprintf(CRITICAL, " CS: %04x EIP: %08x EFL: %08x CR2: %08x\n",
frame->cs, frame->eip, frame->eflags, x86_get_cr2());
dprintf(CRITICAL, "EAX: %08x ECX: %08x EDX: %08x EBX: %08x\n",
frame->eax, frame->ecx, frame->edx, frame->ebx);
dprintf(CRITICAL, "ESP: %08x EBP: %08x ESI: %08x EDI: %08x\n",
frame->esp, frame->ebp, frame->esi, frame->edi);
dprintf(CRITICAL, " DS: %04x ES: %04x FS: %04x GS: %04x\n",
frame->ds, frame->es, frame->fs, frame->gs);
// dump the bottom of the current stack
addr_t stack = (addr_t) frame; //(addr_t) (((uint32_t *) frame) + (sizeof(struct x86_iframe) / sizeof(uint32_t) - 1));
if (stack != 0) {
dprintf(CRITICAL, "bottom of stack at 0x%08x:\n", (unsigned int)stack);
hexdump((void *)stack, 192);
}
}
static void exception_die(struct x86_iframe *frame, const char *msg)
{
inc_critical_section();
dprintf(CRITICAL, msg);
dump_fault_frame(frame);
for (;;) {
x86_cli();
x86_hlt();
}
}
void x86_syscall_handler(struct x86_iframe *frame)
{
exception_die(frame, "unhandled syscall, halting\n");
}
void x86_gpf_handler(struct x86_iframe *frame)
{
exception_die(frame, "unhandled gpf, halting\n");
}
void x86_invop_handler(struct x86_iframe *frame)
{
exception_die(frame, "unhandled invalid op, halting\n");
}
void x86_unhandled_exception(struct x86_iframe *frame)
{
exception_die(frame, "unhandled exception, halting\n");
}
+33
View File
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __X86_ARCH_THREAD_H
#define __X86_ARCH_THREAD_H
struct arch_thread {
vaddr_t esp;
// TODO: fpu context
};
#endif
+32
View File
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_CPU_H
#define __ARCH_CPU_H
#define PAGE_SIZE 4096
// TODO: define to resolve to platform setup discovered value
#define CACHE_LINE 32
#endif
+264
View File
@@ -0,0 +1,264 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_X86_H
#define __ARCH_X86_H
#include <compiler.h>
#include <sys/types.h>
#if defined(__cplusplus)
extern "C" {
#endif
void x86_mmu_init(void);
struct x86_iframe {
uint32_t pivot; // stack switch pivot
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax; // pushed by common handler using pusha
uint32_t ds, es, fs, gs; // pushed by common handler
uint32_t vector; // pushed by stub
uint32_t err_code; // pushed by interrupt or stub
uint32_t eip, cs, eflags; // pushed by interrupt
uint32_t user_esp, user_ss; // pushed by interrupt if priv change occurs
};
/*
* x86 TSS structure
*/
typedef struct {
uint16_t backlink, __blh;
uint32_t esp0;
uint16_t ss0, __ss0h;
uint32_t esp1;
uint16_t ss1, __ss1h;
uint32_t esp2;
uint16_t ss2, __ss2h;
uint32_t cr3;
uint32_t eip;
uint32_t eflags;
uint32_t eax, ecx, edx, ebx;
uint32_t esp, ebp, esi, edi;
uint16_t es, __esh;
uint16_t cs, __csh;
uint16_t ss, __ssh;
uint16_t ds, __dsh;
uint16_t fs, __fsh;
uint16_t gs, __gsh;
uint16_t ldt, __ldth;
uint16_t trace, bitmap;
uint8_t tss_bitmap[8192];
} __PACKED tss_t;
#define X86_CR0_PE 0x00000001 /* protected mode enable */
#define X86_CR0_MP 0x00000002 /* monitor coprocessor */
#define X86_CR0_EM 0x00000004 /* emulation */
#define X86_CR0_TS 0x00000008 /* task switched */
#define X86_CR0_WP 0x00010000 /* supervisor write protect */
#define X86_CR0_NW 0x20000000 /* not write-through */
#define X86_CR0_CD 0x40000000 /* cache disable */
#define X86_CR0_PG 0x80000000 /* enable paging */
static inline void set_in_cr0(uint32_t mask) {
__asm__ __volatile__ (
"movl %%cr0,%%eax \n\t"
"orl %0,%%eax \n\t"
"movl %%eax,%%cr0 \n\t"
: : "irg" (mask)
:"ax");
}
static inline void clear_in_cr0(uint32_t mask) {
__asm__ __volatile__ (
"movl %%cr0, %%eax \n\t"
"andl %0, %%eax \n\t"
"movl %%eax, %%cr0 \n\t"
: : "irg" (~mask)
: "ax");
}
static inline void x86_clts(void) {__asm__ __volatile__ ("clts"); }
static inline void x86_hlt(void) {__asm__ __volatile__ ("hlt"); }
static inline void x86_sti(void) {__asm__ __volatile__ ("sti"); }
static inline void x86_cli(void) {__asm__ __volatile__ ("cli"); }
static inline void x86_ltr(uint16_t sel) {
__asm__ __volatile__ ("ltr %%ax" :: "a" (sel));
}
static inline uint32_t x86_get_cr2(void) {
uint32_t rv;
__asm__ __volatile__ (
"movl %%cr2, %0"
: "=r" (rv)
);
return rv;
}
#define rdtsc(low,high) \
__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
#define rdtscl(low) \
__asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
#define rdtscll(val) \
__asm__ __volatile__("rdtsc" : "=A" (val))
static inline uint8_t inp(uint16_t _port) {
uint8_t rv;
__asm__ __volatile__ ("inb %1, %0"
: "=a" (rv)
: "d" (_port));
return(rv);
}
static inline uint16_t inpw (uint16_t _port) {
uint16_t rv;
__asm__ __volatile__ ("inw %1, %0"
: "=a" (rv)
: "d" (_port));
return(rv);
}
static inline uint32_t inpd(uint16_t _port) {
uint32_t rv;
__asm__ __volatile__ ("inl %1, %0"
: "=a" (rv)
: "d" (_port));
return(rv);
}
static inline void outp(uint16_t _port, uint8_t _data) {
__asm__ __volatile__ ("outb %1, %0"
:
: "d" (_port),
"a" (_data));
}
static inline void outpw(uint16_t _port, uint16_t _data) {
__asm__ __volatile__ ("outw %1, %0"
:
: "d" (_port),
"a" (_data));
}
static inline void outpd(uint16_t _port, uint32_t _data) {
__asm__ __volatile__ ("outl %1, %0"
:
: "d" (_port),
"a" (_data));
}
static inline void inprep(uint16_t _port, uint8_t *_buffer, uint32_t _reads) {
__asm__ __volatile__ ("pushal \n\t"
"pushfl \n\t"
"cli \n\t"
"cld \n\t"
"rep insb \n\t"
"popfl \n\t"
"popal"
:
: "d" (_port),
"D" (_buffer),
"c" (_reads));
}
static inline void outprep(uint16_t _port, uint8_t *_buffer, uint32_t _writes) {
__asm__ __volatile__ ("pushal \n\t"
"pushfl \n\t"
"cli \n\t"
"cld \n\t"
"rep outsb \n\t"
"popfl \n\t"
"popal"
:
: "d" (_port),
"S" (_buffer),
"c" (_writes));
}
static inline void inpwrep(uint16_t _port, uint16_t *_buffer, uint32_t _reads) {
__asm__ __volatile__ ("pushal \n\t"
"pushfl \n\t"
"cli \n\t"
"cld \n\t"
"rep insw \n\t"
"popfl \n\t"
"popal"
:
: "d" (_port),
"D" (_buffer),
"c" (_reads));
}
static inline void outpwrep(uint16_t _port, uint16_t *_buffer,
uint32_t _writes) {
__asm__ __volatile__ ("pushal \n\t"
"pushfl \n\t"
"cli \n\t"
"cld \n\t"
"rep outsw \n\t"
"popfl \n\t"
"popal"
:
: "d" (_port),
"S" (_buffer),
"c" (_writes));
}
static inline void inpdrep(uint16_t _port, uint32_t *_buffer,
uint32_t _reads) {
__asm__ __volatile__ ("pushal \n\t"
"pushfl \n\t"
"cli \n\t"
"cld \n\t"
"rep insl \n\t"
"popfl \n\t"
"popal"
:
: "d" (_port),
"D" (_buffer),
"c" (_reads));
}
static inline void outpdrep(uint16_t _port, uint32_t *_buffer,
uint32_t _writes) {
__asm__ __volatile__ ("pushal \n\t"
"pushfl \n\t"
"cli \n\t"
"cld \n\t"
"rep outsl \n\t"
"popfl \n\t"
"popal"
:
: "d" (_port),
"S" (_buffer),
"c" (_writes));
}
#if defined(__cplusplus)
}
#endif
#endif
+54
View File
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_DESCRIPTOR_H
#define __ARCH_DESCRIPTOR_H
#include <sys/types.h>
/*
* System Selectors
*/
#define CODE_SELECTOR 0x08
#define DATA_SELECTOR 0x10
#define VIDEO_SELECTOR 0x18
#define TSS_SELECTOR 0x30
#define USER_CODE_SELECTOR 0x23
#define USER_DATA_SELECTOR 0x2b
/*
* Descriptor Types
*/
#define SEG_TYPE_TSS 0x9
#define SEG_TYPE_TSS_BUSY 0xb
#define SEG_TYPE_TASK_GATE 0x5
#define SEG_TYPE_INT_GATE 0xe // 32 bit
#define SEG_TYPE_DATA_RW 0x2
#define SEG_TYPE_CODE_RW 0xa
typedef uint16_t seg_sel_t;
void set_global_desc(seg_sel_t sel, void *base, uint32_t limit,
uint8_t present, uint8_t ring, uint8_t sys, uint8_t type, uint8_t gran, uint8_t bits);
#endif
+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_ARM_MMU_H
#define __ARCH_ARM_MMU_H
#include <sys/types.h>
#if defined(__cplusplus)
extern "C" {
#endif
void arm_mmu_init(void);
#define MMU_FLAG_CACHED 0x1
#define MMU_FLAG_BUFFERED 0x2
#define MMU_FLAG_READWRITE 0x4
void arm_mmu_map_section(addr_t paddr, addr_t vaddr, uint flags);
#if defined(__cplusplus)
}
#endif
#endif
+46
View File
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ARCH_X86_OPS_H
#define __ARHC_X86_OPS_H
#if 0
#include <compiler.h>
#ifndef ASSEMBLY
// override of some routines
__GNU_INLINE __ALWAYS_INLINE extern inline void arch_enable_ints(void)
{
__asm__ __volatile__ ("sti");
}
__GNU_INLINE __ALWAYS_INLINE extern inline void arch_disable_ints(void)
{
__asm__ __volatile__ ("cli");
}
#endif
#endif
#endif
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
ENTRY(_start)
SECTIONS
{
.text 0x0200000 : {
*(.text)
*(SORT(.text$*))
*(.gnu.linkonce.t.*)
__ctor_list = .;
*(SORT(.ctor*))
__ctor_end = .;
__dtor_list = .;
*(SORT(.dtor*))
__dtor_end = .;
. = ALIGN(4096);
}
__data_start = .;
.data : { *(.data .data.* .gnu.linkonce.d.*) }
.stab : { *(.stab) }
.stabst : { *(.stabstr) }
. = ALIGN(4096);
__data_end = .;
.rdata : {
*(.rdata)
*(SORT(.rdata$*))
*(.rodata*)
*(.gnu.linkonce.r.*)
__commands_start = .;
KEEP (*(.commands))
__commands_end = .;
. = ALIGN(4);
__apps_start = .;
KEEP (*(.apps))
__apps_end = .;
. = ALIGN(4096);
}
__bss_start = .;
.bss : {
*(.bss*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4096);
}
__bss_end = .;
/*. += 0x2000;
_kstack = .;
. += 0x1000;*/
_end = .;
/DISCARD/ : { *(.comment .note .eh_frame) }
}
+44
View File
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <sys/types.h>
#include <compiler.h>
#include <arch.h>
#include <arch/x86.h>
#include <arch/x86/mmu.h>
void x86_mmu_map_section(addr_t paddr, addr_t vaddr, uint flags)
{
// TODO: stuff
//x86_invalidate_tlb();
}
void x86_mmu_init(void)
{
// TODO: stuff
}
void arch_disable_mmu(void)
{
// TODO: stuff
}
+97
View File
@@ -0,0 +1,97 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <asm.h>
.text
/* void arch_enable_ints(void); */
FUNCTION(arch_enable_ints)
sti
ret
/* void arch_disable_ints(void); */
FUNCTION(arch_disable_ints)
cli
ret
/* int atomic_swap(int *ptr, int val); */
FUNCTION(atomic_swap)
movl 4(%esp), %edx
movl 8(%esp), %eax
xchgl %eax, (%edx)
ret
/* int atomic_add(int *ptr, int val); */
FUNCTION(atomic_add)
movl 4(%esp), %edx
movl 8(%esp), %eax
lock
xadd %eax, (%edx)
ret
/* int atomic_and(int *ptr, int val); */
FUNCTION(atomic_and)
movl 4(%esp), %edx
movl (%edx), %eax
0:
movl %eax, %ecx
andl 8(%esp), %ecx
lock
cmpxchgl %ecx, (%edx)
jnz 1f /* static prediction: branch forward not taken */
ret
1:
jmp 0b
/* int atomic_or(int *ptr, int val); */
FUNCTION(atomic_or)
movl 4(%esp), %edx
movl (%edx), %eax
0:
movl %eax, %ecx
orl 8(%esp), %ecx
lock
cmpxchgl %ecx, (%edx)
jnz 1f /* static prediction: branch forward not taken */
ret
1:
jmp 0b
/* void arch_idle(); */
FUNCTION(arch_idle)
pushf
popl %eax
andl $0x200, %eax
test %eax, %eax
je 1f /* don't halt if local interrupts are disabled */
hlt
1:
ret
/* void arch_switch_stacks_and_call(addr_t call, addr_t stack) */
FUNCTION(arch_switch_stacks_and_call)
movl 4(%esp), %eax
movl 8(%esp), %edx
movl %edx, %esp
call *%eax /* perhaps this should be a jmp? it's not used anywhere so I don't know. */
+41
View File
@@ -0,0 +1,41 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += \
-I$(LOCAL_DIR)/include
BOOTOBJS += \
$(LOCAL_DIR)/crt0.o
OBJS += \
$(LOCAL_DIR)/arch.o \
$(LOCAL_DIR)/asm.o \
$(LOCAL_DIR)/cache.o \
$(LOCAL_DIR)/cache-ops.o \
$(LOCAL_DIR)/ops.o \
$(LOCAL_DIR)/thread.o \
$(LOCAL_DIR)/mmu.o \
$(LOCAL_DIR)/faults.o \
$(LOCAL_DIR)/descriptor.o
# set the default toolchain to x86 elf and set a #define
TOOLCHAIN_PREFIX ?= i386-elf-
LIBGCC := $(shell $(TOOLCHAIN_PREFIX)gcc $(CFLAGS) -print-libgcc-file-name)
#$(info LIBGCC = $(LIBGCC))
cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`"; \
then echo "$(2)"; else echo "$(3)"; fi ;)
# disable SSP if the compiler supports it; it will break stuff
CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
# potentially generated files that should be cleaned out with clean make rule
GENERATED += \
$(BUILDDIR)/kernel.ld
# rules for generating the linker scripts
$(BUILDDIR)/kernel.ld: $(LOCAL_DIR)/kernel.ld
@echo generating $@
@$(MKDIR)
$(NOECHO)cp $< $@
+129
View File
@@ -0,0 +1,129 @@
/*
* Copyright (c) 2009 Corey Tabaka
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <debug.h>
#include <kernel/thread.h>
#include <arch/x86.h>
#include <arch/x86/descriptor.h>
/*struct context_switch_frame {
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
uint32_t ds, es, fs, gs;
uint32_t eip, cs, eflags;
};*/
struct context_switch_frame {
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
uint32_t eflags;
uint32_t eip;
};
extern void x86_context_switch(addr_t *old_sp, addr_t new_sp);
static void initial_thread_func(void) __NO_RETURN;
static void initial_thread_func(void)
{
int ret;
// dprintf("initial_thread_func: thread %p calling %p with arg %p\n", current_thread, current_thread->entry, current_thread->arg);
// dump_thread(current_thread);
/* exit the implicit critical section we're within */
exit_critical_section();
ret = current_thread->entry(current_thread->arg);
// dprintf("initial_thread_func: thread %p exiting with %d\n", current_thread, ret);
thread_exit(ret);
}
void arch_thread_initialize(thread_t *t)
{
// create a default stack frame on the stack
vaddr_t stack_top = (vaddr_t)t->stack + t->stack_size;
// make sure the top of the stack is 8 byte aligned for EABI compliance
stack_top = ROUNDDOWN(stack_top, 8);
struct context_switch_frame *frame = (struct context_switch_frame *)(stack_top);
frame--;
// fill it in
memset(frame, 0, sizeof(*frame));
frame->eip = (vaddr_t) &initial_thread_func;
frame->eflags = 0x3002; // IF = 0, NT = 0, IOPL = 3
//frame->cs = CODE_SELECTOR;
//frame->fs = DATA_SELECTOR;
//frame->gs = DATA_SELECTOR;
//frame->es = DATA_SELECTOR;
//frame->ds = DATA_SELECTOR;
// set the stack pointer
t->arch.esp = (vaddr_t)frame;
}
void arch_context_switch(thread_t *oldthread, thread_t *newthread)
{
//dprintf(DEBUG, "arch_context_switch: old %p (%s), new %p (%s)\n", oldthread, oldthread->name, newthread, newthread->name);
__asm__ __volatile__ (
"pushl $1f \n\t"
"pushf \n\t"
"pusha \n\t"
"movl %%esp,(%%edx) \n\t"
"movl %%eax,%%esp \n\t"
"popa \n\t"
"popf \n\t"
"ret \n\t"
"1: \n\t"
:
: "d" (&oldthread->arch.esp), "a" (newthread->arch.esp)
);
/*__asm__ __volatile__ (
"pushf \n\t"
"pushl %%cs \n\t"
"pushl $1f \n\t"
"pushl %%gs \n\t"
"pushl %%fs \n\t"
"pushl %%es \n\t"
"pushl %%ds \n\t"
"pusha \n\t"
"movl %%esp,(%%edx) \n\t"
"movl %%eax,%%esp \n\t"
"popa \n\t"
"popl %%ds \n\t"
"popl %%es \n\t"
"popl %%fs \n\t"
"popl %%gs \n\t"
"iret \n\t"
"1: "
:
: "d" (&oldthread->arch.esp), "a" (newthread->arch.esp)
);*/
}
+28
View File
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
void dev_init(void)
{
}
+392
View File
@@ -0,0 +1,392 @@
/*
* Copyright (c) 2008, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <debug.h>
#include <err.h>
#include <stdlib.h>
#include <dev/fbcon.h>
#include <splash.h>
#include <platform.h>
#include <string.h>
#include "font5x12.h"
struct pos {
int x;
int y;
};
static struct fbcon_config *config = NULL;
#define RGB565_BLACK 0x0000
#define RGB565_WHITE 0xffff
#define RGB888_BLACK 0x000000
#define RGB888_WHITE 0xffffff
#define FONT_WIDTH 5
#define FONT_HEIGHT 12
#if DISPLAY_TYPE_TOUCHPAD
unsigned char BGCOLOR_R;
unsigned char BGCOLOR_G;
unsigned char BGCOLOR_B;
unsigned char FGCOLOR_R;
unsigned char FGCOLOR_G;
unsigned char FGCOLOR_B;
#else
static uint16_t BGCOLOR;
static uint16_t FGCOLOR;
#endif
static struct pos cur_pos;
static struct pos max_pos;
#if DISPLAY_TYPE_TOUCHPAD
void fb_put_pixel(unsigned x, unsigned y, unsigned char red, unsigned char green, unsigned char blue)
{
volatile void *fb_addr = (void *)0x7f600000;
unsigned int pixel_size = 4;
unsigned long line_size = 1024*pixel_size;
volatile void *pixel_loc;
if (x >= 1024) return;
if (y >= 768) return;
pixel_loc = fb_addr + y * line_size + x * pixel_size;
*((unsigned char *)(pixel_loc + 0)) = blue; // blue
*((unsigned char *)(pixel_loc + 1)) = green; // grn
*((unsigned char *)(pixel_loc + 2)) = red; // red
*((unsigned char *)(pixel_loc + 3)) = 0; // ??
}
static void fbcon_drawglyph_tp(unsigned x, unsigned y, unsigned *glyph)
{
unsigned xd, yd, data;
data = glyph[0];
for (yd = 0; yd < (FONT_HEIGHT / 2); ++yd) {
for (xd = 0; xd < FONT_WIDTH; ++xd) {
if (data & 1) {
fb_put_pixel(x+xd, y+yd, FGCOLOR_R, FGCOLOR_G, FGCOLOR_B);
} else {
fb_put_pixel(x+xd, y+yd, BGCOLOR_R, BGCOLOR_G, BGCOLOR_B);
}
data >>= 1;
}
fb_put_pixel(x+FONT_WIDTH, y+yd, BGCOLOR_R, BGCOLOR_G, BGCOLOR_B);
}
data = glyph[1];
for (yd = 0; yd < (FONT_HEIGHT / 2); yd++) {
for (xd = 0; xd < FONT_WIDTH; xd++) {
if (data & 1) {
fb_put_pixel(x+xd, y+yd+(FONT_HEIGHT/2), FGCOLOR_R, FGCOLOR_G, FGCOLOR_B);
} else {
fb_put_pixel(x+xd, y+yd+(FONT_HEIGHT/2), BGCOLOR_R, BGCOLOR_G, BGCOLOR_B);
}
data >>= 1;
}
fb_put_pixel(x+FONT_WIDTH, y+yd+(FONT_HEIGHT/2), BGCOLOR_R, BGCOLOR_G, BGCOLOR_B);
}
}
#endif
static void fbcon_drawglyph(uint16_t *pixels, uint16_t paint, unsigned stride,
unsigned *glyph)
{
unsigned x, y, data;
stride -= FONT_WIDTH;
data = glyph[0];
for (y = 0; y < (FONT_HEIGHT / 2); ++y) {
for (x = 0; x < FONT_WIDTH; ++x) {
if (data & 1)
*pixels = paint;
data >>= 1;
pixels++;
}
pixels += stride;
}
data = glyph[1];
for (y = 0; y < (FONT_HEIGHT / 2); y++) {
for (x = 0; x < FONT_WIDTH; x++) {
if (data & 1)
*pixels = paint;
data >>= 1;
pixels++;
}
pixels += stride;
}
}
static void fbcon_flush(void)
{
if (config->update_start)
config->update_start();
if (config->update_done)
while (!config->update_done());
}
/* TODO: Take stride into account */
static void fbcon_scroll_up(void)
{
#if DISPLAY_TYPE_TOUCHPAD
for (unsigned y = 0; y <= max_pos.y - FONT_HEIGHT; y += FONT_HEIGHT) {
memcpy (config->base + y * 1024*4,
config->base + (y + FONT_HEIGHT) * 1024*4,
1024*4*FONT_HEIGHT);
}
for (unsigned y = max_pos.y; y < config->height; y++) {
memset(config->base + y*1024*4, 0, 1024*4);
}
#else
unsigned short *dst = config->base;
unsigned short *src = dst + (config->width * FONT_HEIGHT);
unsigned count = config->width * (config->height - FONT_HEIGHT);
while(count--) {
*dst++ = *src++;
}
count = config->width * FONT_HEIGHT;
while(count--) {
*dst++ = BGCOLOR;
}
#endif
fbcon_flush();
}
/* TODO: take stride into account */
void fbcon_clear(void)
{
#if DISPLAY_TYPE_TOUCHPAD
for (unsigned y = 0; y < 1024; y++) {
memset(config->base + y*1024*4, 0, 1024*4);
}
#else
unsigned count = config->width * config->height;
memset(config->base, BGCOLOR, count * ((config->bpp) / 8));
#endif
}
#if DISPLAY_TYPE_TOUCHPAD
void fbcon_set_colors(
unsigned char bg_r,
unsigned char bg_g,
unsigned char bg_b,
unsigned char fg_r,
unsigned char fg_g,
unsigned char fg_b
)
{
BGCOLOR_R = bg_r;
BGCOLOR_G = bg_g;
BGCOLOR_B = bg_b;
FGCOLOR_R = fg_r;
FGCOLOR_G = fg_g;
FGCOLOR_B = fg_b;
}
#else
static void fbcon_set_colors(unsigned bg, unsigned fg)
{
BGCOLOR = bg;
FGCOLOR = fg;
}
#endif
#if DISPLAY_TYPE_TOUCHPAD
void fbcon_setpos(unsigned x, unsigned y)
{
unsigned newx, newy;
newx = x * (FONT_WIDTH + 1);
newy = y * (FONT_HEIGHT);
if (newx > max_pos.x || newy > max_pos.y) {
return;
} else {
cur_pos.x = newx;
cur_pos.y = newy;
}
}
#endif
void fbcon_putc(char c)
{
uint16_t *pixels;
/* ignore anything that happens before fbcon is initialized */
if (!config)
return;
if((unsigned char)c > 127)
return;
if((unsigned char)c < 32) {
if(c == '\n')
goto newline;
else if (c == '\r')
cur_pos.x = 0;
return;
}
#if DISPLAY_TYPE_TOUCHPAD
fbcon_drawglyph_tp(cur_pos.x, cur_pos.y,
font5x12 + (c - 32) * 2);
cur_pos.x += FONT_WIDTH + 1;
if (cur_pos.x <= max_pos.x)
return;
newline:
cur_pos.y += FONT_HEIGHT;
cur_pos.x = 0;
if(cur_pos.y > max_pos.y) {
cur_pos.y -= FONT_HEIGHT;
fbcon_scroll_up();
} else
fbcon_flush();
#else
pixels = config->base;
pixels += cur_pos.y * FONT_HEIGHT * config->width;
pixels += cur_pos.x * (FONT_WIDTH + 1);
fbcon_drawglyph(pixels, FGCOLOR, config->stride,
font5x12 + (c - 32) * 2);
cur_pos.x++;
if (cur_pos.x < max_pos.x)
return;
newline:
cur_pos.y++;
cur_pos.x = 0;
if(cur_pos.y >= max_pos.y) {
cur_pos.y = max_pos.y - 1;
fbcon_scroll_up();
} else
fbcon_flush();
#endif
}
void fbcon_setup(struct fbcon_config *_config)
{
uint32_t bg;
uint32_t fg;
ASSERT(_config);
config = _config;
switch (config->format) {
case FB_FORMAT_RGB565:
fg = RGB565_WHITE;
bg = RGB565_BLACK;
break;
case FB_FORMAT_RGB888:
fg = RGB888_WHITE;
bg = RGB888_BLACK;
break;
default:
dprintf(CRITICAL, "unknown framebuffer pixel format\n");
ASSERT(0);
break;
}
#if DISPLAY_TYPE_TOUCHPAD
fbcon_set_colors(0, 0, 0, 0, 0, 255);
#else
fbcon_set_colors(bg, fg);
#endif
cur_pos.x = 0;
cur_pos.y = 0;
#if DISPLAY_TYPE_TOUCHPAD
max_pos.x = config->width - FONT_WIDTH;
max_pos.y = config->height - FONT_HEIGHT;
#else
max_pos.x = config->width / (FONT_WIDTH+1);
max_pos.y = (config->height - 1) / FONT_HEIGHT;
#endif
#if !DISPLAY_SPLASH_SCREEN
fbcon_clear();
#endif
}
struct fbcon_config* fbcon_display(void)
{
return config;
}
void display_image_on_screen(void)
{
unsigned i = 0;
unsigned total_x = config->width;
unsigned total_y = config->height;
unsigned bytes_per_bpp = ((config->bpp) / 8);
unsigned image_base = ((((total_y/2) - (SPLASH_IMAGE_WIDTH / 2) - 1) *
(config->width)) + (total_x/2 - (SPLASH_IMAGE_HEIGHT / 2)));
fbcon_clear();
#if DISPLAY_TYPE_MIPI
if (bytes_per_bpp == 3)
{
for (i = 0; i < SPLASH_IMAGE_WIDTH; i++)
{
memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp),
imageBuffer_rgb888 + (i * SPLASH_IMAGE_HEIGHT * bytes_per_bpp),
SPLASH_IMAGE_HEIGHT * bytes_per_bpp);
}
}
fbcon_flush();
#if DISPLAY_MIPI_PANEL_NOVATEK_BLUE
if(is_cmd_mode_enabled())
mipi_dsi_cmd_mode_trigger();
#endif
#elif DISPLAY_TYPE_TOUCHPAD
/* not supported yet */
return;
#else
if (bytes_per_bpp == 2)
{
for (i = 0; i < SPLASH_IMAGE_WIDTH; i++)
{
memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp),
imageBuffer + (i * SPLASH_IMAGE_HEIGHT * bytes_per_bpp),
SPLASH_IMAGE_HEIGHT * bytes_per_bpp);
}
}
fbcon_flush();
#endif
}
+126
View File
@@ -0,0 +1,126 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
unsigned font5x12[] = {
0x00000000, 0x00000000,
0x08421080, 0x00020084,
0x00052940, 0x00000000,
0x15f52800, 0x0000295f,
0x1c52f880, 0x00023e94,
0x08855640, 0x0004d542,
0x04528800, 0x000b2725,
0x00021080, 0x00000000,
0x04211088, 0x00821042,
0x10841082, 0x00221108,
0x09575480, 0x00000000,
0x3e420000, 0x00000084,
0x00000000, 0x00223000,
0x3e000000, 0x00000000,
0x00000000, 0x00471000,
0x08844200, 0x00008442,
0x2318a880, 0x00022a31,
0x08429880, 0x000f9084,
0x1108c5c0, 0x000f8444,
0x1c4443e0, 0x00074610,
0x14a62100, 0x000423e9,
0x26d087e0, 0x00074610,
0x1e10c5c0, 0x00074631,
0x088443e0, 0x00010844,
0x1d18c5c0, 0x00074631,
0x3d18c5c0, 0x00074610,
0x08e20000, 0x00471000,
0x08e20000, 0x00223000,
0x02222200, 0x00082082,
0x01f00000, 0x000003e0,
0x20820820, 0x00008888,
0x1108c5c0, 0x00020084,
0x2b98c5c0, 0x000f05b5,
0x2318a880, 0x0008c63f,
0x1d2949e0, 0x0007ca52,
0x0210c5c0, 0x00074421,
0x252949e0, 0x0007ca52,
0x1e1087e0, 0x000f8421,
0x1e1087e0, 0x00008421,
0x0210c5c0, 0x00074639,
0x3f18c620, 0x0008c631,
0x084211c0, 0x00071084,
0x10842380, 0x00032508,
0x0654c620, 0x0008c525,
0x02108420, 0x000f8421,
0x2b5dc620, 0x0008c631,
0x2b59ce20, 0x0008c739,
0x2318c5c0, 0x00074631,
0x1f18c5e0, 0x00008421,
0x2318c5c0, 0x01075631,
0x1f18c5e0, 0x0008c525,
0x1c10c5c0, 0x00074610,
0x084213e0, 0x00021084,
0x2318c620, 0x00074631,
0x1518c620, 0x0002114a,
0x2b18c620, 0x000556b5,
0x08a54620, 0x0008c54a,
0x08a54620, 0x00021084,
0x088443e0, 0x000f8442,
0x0421084e, 0x00e10842,
0x08210420, 0x00084108,
0x1084210e, 0x00e42108,
0x0008a880, 0x00000000,
0x00000000, 0x01f00000,
0x00000104, 0x00000000,
0x20e00000, 0x000b663e,
0x22f08420, 0x0007c631,
0x22e00000, 0x00074421,
0x23e84200, 0x000f4631,
0x22e00000, 0x0007443f,
0x1e214980, 0x00010842,
0x22e00000, 0x1d187a31,
0x26d08420, 0x0008c631,
0x08601000, 0x00071084,
0x10c02000, 0x0c94a108,
0x0a908420, 0x0008a4a3,
0x084210c0, 0x00071084,
0x2ab00000, 0x0008d6b5,
0x26d00000, 0x0008c631,
0x22e00000, 0x00074631,
0x22f00000, 0x0210be31,
0x23e00000, 0x21087a31,
0x26d00000, 0x00008421,
0x22e00000, 0x00074506,
0x04f10800, 0x00064842,
0x23100000, 0x000b6631,
0x23100000, 0x00022951,
0x23100000, 0x000556b5,
0x15100000, 0x0008a884,
0x23100000, 0x1d185b31,
0x11f00000, 0x000f8444,
0x06421098, 0x01821084,
0x08421080, 0x00021084,
0x30421083, 0x00321084,
0x0004d640, 0x00000000,
0x00000000, 0x00000000,
};
+5
View File
@@ -0,0 +1,5 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
OBJS += \
$(LOCAL_DIR)/fbcon.o
+455
View File
@@ -0,0 +1,455 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <assert.h>
#include <bits.h>
#include <stdlib.h>
#include <string.h>
#include <dev/keys.h>
#include <dev/gpio.h>
#include <dev/gpio_keypad.h>
#include <dev/ssbi.h>
#include <kernel/event.h>
#include <kernel/timer.h>
#include <reg.h>
#include <platform/iomap.h>
#include <platform/timer.h>
#include <platform.h>
#define LINUX_MACHTYPE_8660_QT 3298
struct gpio_kp {
struct gpio_keypad_info *keypad_info;
struct timer timer;
event_t full_scan;
int current_output;
unsigned int some_keys_pressed:2;
unsigned long keys_pressed[0];
};
struct gpio_qwerty_kp {
struct qwerty_keypad_info *keypad_info;
struct timer timer;
event_t full_scan;
unsigned int some_keys_pressed:2;
unsigned long keys_pressed[0];
};
static struct gpio_qwerty_kp *qwerty_keypad;
/* TODO: Support multiple keypads? */
static struct gpio_kp *keypad;
static void check_output(struct gpio_kp *kp, int out, int polarity)
{
struct gpio_keypad_info *kpinfo = kp->keypad_info;
int key_index;
int in;
int gpio;
int changed = 0;
key_index = out * kpinfo->ninputs;
for (in = 0; in < kpinfo->ninputs; in++, key_index++) {
gpio = kpinfo->input_gpios[in];
changed = 0;
if (gpio_get(gpio) ^ !polarity) {
if (kp->some_keys_pressed < 3)
kp->some_keys_pressed++;
changed = !bitmap_set(kp->keys_pressed, key_index);
} else {
changed = bitmap_clear(kp->keys_pressed, key_index);
}
if (changed) {
int state = bitmap_test(kp->keys_pressed, key_index);
keys_post_event(kpinfo->keymap[key_index], state);
}
}
/* sets up the right state for the next poll cycle */
gpio = kpinfo->output_gpios[out];
if (kpinfo->flags & GPIOKPF_DRIVE_INACTIVE)
gpio_set(gpio, !polarity);
else
gpio_config(gpio, GPIO_INPUT);
}
static enum handler_return
gpio_keypad_timer_func(struct timer *timer, time_t now, void *arg)
{
struct gpio_kp *kp = keypad;
struct gpio_keypad_info *kpinfo = kp->keypad_info;
int polarity = !!(kpinfo->flags & GPIOKPF_ACTIVE_HIGH);
int out;
int gpio;
out = kp->current_output;
if (out == kpinfo->noutputs) {
out = 0;
kp->some_keys_pressed = 0;
} else {
check_output(kp, out, polarity);
out++;
}
kp->current_output = out;
if (out < kpinfo->noutputs) {
gpio = kpinfo->output_gpios[out];
if (kpinfo->flags & GPIOKPF_DRIVE_INACTIVE)
gpio_set(gpio, polarity);
else
gpio_config(gpio, polarity ? GPIO_OUTPUT : 0);
timer_set_oneshot(timer, kpinfo->settle_time,
gpio_keypad_timer_func, NULL);
goto done;
}
if (/*!kp->use_irq*/ 1 || kp->some_keys_pressed) {
event_signal(&kp->full_scan, false);
timer_set_oneshot(timer, kpinfo->poll_time,
gpio_keypad_timer_func, NULL);
goto done;
}
done:
return INT_RESCHEDULE;
}
void gpio_keypad_init(struct gpio_keypad_info *kpinfo)
{
int key_count;
int output_val;
int output_cfg;
int i;
int len;
ASSERT(kpinfo->keymap && kpinfo->input_gpios && kpinfo->output_gpios);
key_count = kpinfo->ninputs * kpinfo->noutputs;
len = sizeof(struct gpio_kp) + (sizeof(unsigned long) *
BITMAP_NUM_WORDS(key_count));
keypad = malloc(len);
ASSERT(keypad);
memset(keypad, 0, len);
keypad->keypad_info = kpinfo;
output_val = (!!(kpinfo->flags & GPIOKPF_ACTIVE_HIGH)) ^
(!!(kpinfo->flags & GPIOKPF_DRIVE_INACTIVE));
output_cfg = kpinfo->flags & GPIOKPF_DRIVE_INACTIVE ? GPIO_OUTPUT : 0;
for (i = 0; i < kpinfo->noutputs; i++) {
gpio_set(kpinfo->output_gpios[i], output_val);
gpio_config(kpinfo->output_gpios[i], output_cfg);
}
for (i = 0; i < kpinfo->ninputs; i++)
gpio_config(kpinfo->input_gpios[i], GPIO_INPUT);
keypad->current_output = kpinfo->noutputs;
event_init(&keypad->full_scan, false, EVENT_FLAG_AUTOUNSIGNAL);
timer_initialize(&keypad->timer);
timer_set_oneshot(&keypad->timer, 0, gpio_keypad_timer_func, NULL);
/* wait for the keypad to complete one full scan */
event_wait(&keypad->full_scan);
}
int pm8058_gpio_config(int gpio, struct pm8058_gpio *param)
{
int rc;
write_func wr_function = (qwerty_keypad->keypad_info)->wr_func;
unsigned char bank[8];
static int dir_map[] = {
PM8058_GPIO_MODE_OFF,
PM8058_GPIO_MODE_OUTPUT,
PM8058_GPIO_MODE_INPUT,
PM8058_GPIO_MODE_BOTH,
};
if (param == 0) {
dprintf (INFO, "pm8058_gpio struct not defined\n");
return -1;
}
/* Select banks and configure the gpio */
bank[0] = PM8058_GPIO_WRITE |
((param->vin_sel << PM8058_GPIO_VIN_SHIFT) &
PM8058_GPIO_VIN_MASK) |
PM8058_GPIO_MODE_ENABLE;
bank[1] = PM8058_GPIO_WRITE |
((1 << PM8058_GPIO_BANK_SHIFT) & PM8058_GPIO_BANK_MASK) |
((dir_map[param->direction] << PM8058_GPIO_MODE_SHIFT) &
PM8058_GPIO_MODE_MASK) |
((param->direction & PM_GPIO_DIR_OUT) ?
PM8058_GPIO_OUT_BUFFER : 0);
bank[2] = PM8058_GPIO_WRITE |
((2 << PM8058_GPIO_BANK_SHIFT) & PM8058_GPIO_BANK_MASK) |
((param->pull << PM8058_GPIO_PULL_SHIFT) &
PM8058_GPIO_PULL_MASK);
bank[3] = PM8058_GPIO_WRITE |
((3 << PM8058_GPIO_BANK_SHIFT) & PM8058_GPIO_BANK_MASK) |
((param->out_strength << PM8058_GPIO_OUT_STRENGTH_SHIFT) &
PM8058_GPIO_OUT_STRENGTH_MASK);
bank[4] = PM8058_GPIO_WRITE |
((4 << PM8058_GPIO_BANK_SHIFT) & PM8058_GPIO_BANK_MASK) |
((param->function << PM8058_GPIO_FUNC_SHIFT) &
PM8058_GPIO_FUNC_MASK);
rc = (*wr_function)(bank, 5, SSBI_REG_ADDR_GPIO(gpio));
if (rc) {
dprintf(INFO, "Failed on 1st ssbi_write(): rc=%d.\n", rc);
return 1;
}
return 0;
}
int pm8058_gpio_config_kypd_drv(int gpio_start, int num_gpios, unsigned mach_id)
{
int rc;
struct pm8058_gpio kypd_drv = {
.direction = PM_GPIO_DIR_OUT,
.pull = PM_GPIO_PULL_NO,
.vin_sel = 2,
.out_strength = PM_GPIO_STRENGTH_LOW,
.function = PM_GPIO_FUNC_1,
.inv_int_pol = 1,
};
if(mach_id == LINUX_MACHTYPE_8660_QT)
kypd_drv.function = PM_GPIO_FUNC_NORMAL;
while (num_gpios--) {
rc = pm8058_gpio_config(gpio_start++, &kypd_drv);
if (rc) {
dprintf(INFO, "FAIL pm8058_gpio_config(): rc=%d.\n", rc);
return rc;
}
}
return 0;
}
int pm8058_gpio_config_kypd_sns(int gpio_start, int num_gpios)
{
int rc;
struct pm8058_gpio kypd_sns = {
.direction = PM_GPIO_DIR_IN,
.pull = PM_GPIO_PULL_UP1,
.vin_sel = 2,
.out_strength = PM_GPIO_STRENGTH_NO,
.function = PM_GPIO_FUNC_NORMAL,
.inv_int_pol = 1,
};
while (num_gpios--) {
rc = pm8058_gpio_config(gpio_start++, &kypd_sns);
if (rc) {
dprintf(INFO, "FAIL pm8058_gpio_config(): rc=%d.\n", rc);
return rc;
}
}
return 0;
}
static void ssbi_gpio_init(unsigned int mach_id)
{
unsigned char kypd_cntl_init;
unsigned char kypd_scan_init = 0x20;
int rows = (qwerty_keypad->keypad_info)->rows;
int columns = (qwerty_keypad->keypad_info)->columns;
write_func wr_function = (qwerty_keypad->keypad_info)->wr_func;
unsigned char drv_bits[] = {
0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7 };
unsigned char sns_bits[] = { 0, 0, 0, 0, 0, 0, 1, 2, 3 };
kypd_cntl_init = ((drv_bits[rows] << 2) | (sns_bits[columns] << 5) | (1 << 7));
if ((*wr_function)(&kypd_cntl_init, 1, SSBI_REG_KYPD_CNTL_ADDR))
dprintf (CRITICAL, "Error in initializing SSBI_REG_KYPD_CNTL register\n");
if ((*wr_function)(&kypd_scan_init, 1, SSBI_REG_KYPD_SCAN_ADDR))
dprintf (CRITICAL, "Error in initializing SSBI_REG_KYPD_SCAN register\n");
if(mach_id == LINUX_MACHTYPE_8660_QT)
{
pm8058_gpio_config_kypd_sns(QT_PMIC_GPIO_KYPD_SNS, rows);
pm8058_gpio_config_kypd_drv(QT_PMIC_GPIO_KYPD_DRV, columns, mach_id);
}
else
{
pm8058_gpio_config_kypd_sns(SSBI_OFFSET_ADDR_GPIO_KYPD_SNS, columns);
pm8058_gpio_config_kypd_drv(SSBI_OFFSET_ADDR_GPIO_KYPD_DRV, rows, mach_id);
}
}
static enum handler_return
scan_qwerty_keypad(struct timer *timer, time_t now, void *arg)
{
unsigned int rows = (qwerty_keypad->keypad_info)->rows;
unsigned int columns = (qwerty_keypad->keypad_info)->columns;
unsigned int num_of_ssbi_reads = (qwerty_keypad->keypad_info)->num_of_reads;
read_func rd_function = (qwerty_keypad->keypad_info)->rd_func;
unsigned char column_new_keys = 0x00;
unsigned char column_old_keys = 0x00;
int shift = 0;
static int key_detected = -1;
if ((*rd_function)((qwerty_keypad->keypad_info)->rec_keys, num_of_ssbi_reads,
SSBI_REG_KYPD_REC_DATA_ADDR))
dprintf (CRITICAL, "Error in initializing SSBI_REG_KYPD_CNTL register\n");
if ((*rd_function)((qwerty_keypad->keypad_info)->old_keys, num_of_ssbi_reads,
SSBI_REG_KYPD_OLD_DATA_ADDR))
dprintf (CRITICAL, "Error in initializing SSBI_REG_KYPD_CNTL register\n");
while (rows--) {
columns = qwerty_keypad->keypad_info->columns;
if (((qwerty_keypad->keypad_info)->rec_keys[rows]
!= (qwerty_keypad->keypad_info)->old_keys[rows])
&& ((qwerty_keypad->keypad_info)->rec_keys[rows] != 0x00)
&& ((qwerty_keypad->keypad_info)->old_keys[rows] != 0x00)) {
while (columns--) {
column_new_keys = ((qwerty_keypad->keypad_info)->rec_keys[rows]);
column_old_keys = ((qwerty_keypad->keypad_info)->old_keys[rows]);
if (((0x01 << columns) & (~column_new_keys))
&& !((0x01 << columns) & (~column_old_keys))) {
shift = (rows * 8) + columns;
if ((qwerty_keypad->keypad_info)->keymap[shift]) {
if (shift != key_detected) {
key_detected = shift;
keys_post_event((qwerty_keypad->keypad_info)->keymap[shift], 1);
}
}
}
}
}
}
event_signal(&qwerty_keypad->full_scan, false);
return INT_RESCHEDULE;
}
static enum handler_return
scan_qt_keypad(struct timer *timer, time_t now, void *arg)
{
unsigned int gpio;
unsigned int last_state=0;
unsigned int new_state=0;
unsigned int bits_changed;
static int key_detected=-1;
/* Row GPIOs 8,9,10 are used for sensing here */
for (gpio=8;gpio<=10;gpio++)
{
bool status;
status = pm8058_gpio_get(gpio);
if (status == 0)
new_state |= (1<<(gpio-8));
}
bits_changed = last_state ^ new_state;
if (bits_changed)
{
int shift = 0;
for (unsigned int rows = 0; rows < (qwerty_keypad->keypad_info)->rows; rows++)
{
if ((bits_changed & (1<<rows)) == 0)
continue;
shift = rows * 8 + 3;
}
if ((qwerty_keypad->keypad_info)->keymap[shift])
{
if (shift != key_detected)
{
key_detected = shift;
keys_post_event((qwerty_keypad->keypad_info)->keymap[shift], 1);
timer_set_oneshot(timer,(qwerty_keypad->keypad_info)->poll_time,
scan_qt_keypad, NULL);
return INT_RESCHEDULE;
}
}
}
event_signal(&qwerty_keypad->full_scan, false);
return INT_RESCHEDULE;
}
void ssbi_keypad_init(struct qwerty_keypad_info *qwerty_kp)
{
unsigned int mach_id;
int len;
len = sizeof(struct gpio_qwerty_kp);
qwerty_keypad = malloc(len);
ASSERT(qwerty_keypad);
memset(qwerty_keypad, 0, len);
qwerty_keypad->keypad_info = qwerty_kp;
event_init(&qwerty_keypad->full_scan, false, EVENT_FLAG_AUTOUNSIGNAL);
timer_initialize(&qwerty_keypad->timer);
#ifdef QT_8660_KEYPAD_HW_BUG
mach_id = board_machtype();
#endif
ssbi_gpio_init(mach_id);
if(mach_id == LINUX_MACHTYPE_8660_QT)
{
mdelay((qwerty_keypad->keypad_info)->settle_time);
#ifdef QT_8660_KEYPAD_HW_BUG
timer_set_oneshot(&qwerty_keypad->timer, 0, scan_qt_keypad, NULL);
#endif
}
else
timer_set_oneshot(&qwerty_keypad->timer, 0, scan_qwerty_keypad, NULL);
/* wait for the keypad to complete one full scan */
event_wait(&qwerty_keypad->full_scan);
}
void pmic_write(unsigned address, unsigned data)
{
write_func wr_function = &i2c_ssbi_write_bytes;
if (wr_function == NULL)
return;
if ((*wr_function)((unsigned char *) &data, 1, address))
dprintf (CRITICAL, "Error in initializing register\n");
}
void toshiba_pmic_gpio_init(unsigned gpio)
{
pmic_write(gpio,0x85);
pmic_write(gpio,0x98);
pmic_write(gpio,0xB8);
pmic_write(gpio,0xC6);
}
+67
View File
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2008, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <bits.h>
#include <debug.h>
#include <string.h>
#include <dev/keys.h>
static unsigned long key_bitmap[BITMAP_NUM_WORDS(MAX_KEYS)];
void keys_init(void)
{
memset(key_bitmap, 0, sizeof(key_bitmap));
}
void keys_post_event(uint16_t code, int16_t value)
{
if (code >= MAX_KEYS) {
dprintf(INFO, "Invalid keycode posted: %d\n", code);
return;
}
/* TODO: Implement an actual event queue if it becomes necessary */
if (value)
bitmap_set(key_bitmap, code);
else
bitmap_clear(key_bitmap, code);
// dprintf(INFO, "key state change: %d %d\n", code, value);
}
int keys_get_state(uint16_t code)
{
if (code >= MAX_KEYS) {
dprintf(INFO, "Invalid keycode requested: %d\n", code);
return -1;
}
return bitmap_test(key_bitmap, code);
}
+10
View File
@@ -0,0 +1,10 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
OBJS += \
$(LOCAL_DIR)/keys.o
ifeq ($(KEYS_USE_GPIO_KEYPAD),1)
OBJS += \
$(LOCAL_DIR)/gpio_keypad.o
endif
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _DEV_NET_SMC91C96_H
#define _DEV_NET_SMC91C96_H
void smc91c96_init(void);
#endif
+8
View File
@@ -0,0 +1,8 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += \
-I$(LOCAL_DIR)/include
OBJS += \
$(LOCAL_DIR)/smc91c96.o
+70
View File
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <sys/types.h>
#include <debug.h>
#include <printf.h>
#include <dev/net/smc91c96.h>
#include "smc91c96_p.h"
#if !defined(SMC91C96_BASE_ADDR) || !defined(SMC91C96_IRQ)
#error need to define SMC91C96_BASE_ADDR and SMC91C96_IRQ in project
#endif
static addr_t smc91c96_base = SMC91C96_BASE_ADDR;
static uint8_t mac_addr[6];
#define SMC_REG16(reg) ((volatile uint16_t *)(smc91c96_base + (reg)))
#define SMC_REG8(reg) ((volatile uint8_t *)(smc91c96_base + (reg)))
static inline void smc_bank(int bank)
{
*SMC_REG16(SMC_BSR) = bank;
}
void smc91c96_init(void)
{
int i;
TRACE;
// try to detect it
if ((*SMC_REG16(SMC_BSR) & 0xff00) != 0x3300) {
TRACEF("didn't see smc91c96 chip at 0x%x\n", (unsigned int)smc91c96_base);
}
// read revision
smc_bank(3);
TRACEF("detected, revision 0x%x\n", *SMC_REG16(SMC_REV));
// read in the mac address
smc_bank(1);
for (i=0; i < 6; i++) {
mac_addr[i] = *SMC_REG8(SMC_IAR0 + i);
}
TRACEF("mac address %02x:%02x:%02x:%02x:%02x:%02x\n",
mac_addr[0], mac_addr[1], mac_addr[2],
mac_addr[3], mac_addr[4], mac_addr[5]);
smc_bank(0);
}
+80
View File
@@ -0,0 +1,80 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __SMC91C96_P_H
#define __SMC91C96_P_H
// LAN91C96 stuffs
/* registers */
#define SMC_BSR 14
/* bank 0 */
#define SMC_TCR 0
#define SMC_EPHSR 2
#define SMC_RCR 4
#define SMC_ECR 6
#define SMC_MIR 8
#define SMC_MCR 10
/* bank 1 */
#define SMC_CR 0
#define SMC_BAR 2
#define SMC_IAR0 4
#define SMC_IAR1 5
#define SMC_IAR2 6
#define SMC_IAR3 7
#define SMC_IAR4 8
#define SMC_IAR5 9
#define SMC_GPR 10
#define SMC_CTR 12
/* bank 2 */
#define SMC_MMUCR 0
#define SMC_AUTOTX 1
#define SMC_PNR 2
#define SMC_ARR 3
#define SMC_FIFO 4
#define SMC_PTR 6
#define SMC_DATA0 8
#define SMC_DATA1 10
#define SMC_IST 12
#define SMC_ACK 12
#define SMC_MSK 13
/* bank 3 */
#define SMC_MT0 0
#define SMC_MT1 1
#define SMC_MT2 2
#define SMC_MT3 3
#define SMC_MT4 4
#define SMC_MT5 5
#define SMC_MT6 6
#define SMC_MT7 7
#define SMC_MGMT 8
#define SMC_REV 10
#define SMC_ERCV 12
#endif
+106
View File
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DEV_PM8921_H
#define __DEV_PM8921_H
#include <sys/types.h>
#define PM_GPIO_DIR_OUT 0x01
#define PM_GPIO_DIR_IN 0x02
#define PM_GPIO_DIR_BOTH (PM_GPIO_DIR_OUT | PM_GPIO_DIR_IN)
#define PM_GPIO_PULL_UP_30 0
#define PM_GPIO_PULL_UP_31_5 2
/* 1.5uA + 30uA boost */
#define PM_GPIO_PULL_UP_1_5_30 3
#define PM_GPIO_PULL_DN 4
#define PM_GPIO_PULL_NO 5
#define PM_GPIO_STRENGTH_NO 0
#define PM_GPIO_STRENGTH_HIGH 1
#define PM_GPIO_STRENGTH_MED 2
#define PM_GPIO_STRENGTH_LOW 3
#define PM_GPIO_FUNC_NORMAL 0
#define PM_GPIO_FUNC_PAIRED 1
#define PM_GPIO_FUNC_1 2
#define PM_GPIO_FUNC_2 3
/* GPIO24 for backlight_pwm which is 23 (index start at 0) */
#define GPIO_24 23
#define GPIO_43 42
/* LDO define values */
#define LDO_P_MASK (1 << 7)
#define LDO_2 (2)
#define LDO_8 (8 | LDO_P_MASK)
#define LDO_23 (23 | LDO_P_MASK)
enum
{
LDO_VOLTAGE_1_2V = 0,
LDO_VOLTAGE_1_8V = 1,
LDO_VOLTAGE_3_0V = 2,
LDO_VOLTAGE_ENTRIES
};
typedef int (*pm8921_read_func)(uint8_t *data, uint32_t length, uint32_t addr);
typedef int (*pm8921_write_func)(uint8_t *data, uint32_t length, uint32_t addr);
typedef struct
{
uint32_t initialized;
pm8921_read_func read;
pm8921_write_func write;
} pm8921_dev_t;
struct pm8921_gpio {
int direction;
int output_buffer;
int output_value;
int pull;
int vin_sel;
int out_strength;
int function;
int inv_int_pol;
int disable_pin;
};
void pm8921_init(pm8921_dev_t *);
int pm8921_gpio_config(int gpio, struct pm8921_gpio *param);
void pm8921_boot_done(void);
int pm8921_ldo_set_voltage(uint32_t ldo_id, uint32_t voltage);
int pm8921_config_reset_pwr_off(unsigned reset);
#endif
+258
View File
@@ -0,0 +1,258 @@
/*
* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <sys/types.h>
#include <dev/pm8921.h>
#include "pm8921_hw.h"
static pm8921_dev_t *dev;
static uint8_t ldo_n_voltage_mult[LDO_VOLTAGE_ENTRIES] = {
18, /* 1.2V */
0,
0,
};
static uint8_t ldo_p_voltage_mult[LDO_VOLTAGE_ENTRIES] = {
0,
6, /* 1.8V */
30, /* 3.0V */
};
/* Intialize the pmic driver */
void pm8921_init(pm8921_dev_t *pmic)
{
ASSERT(pmic);
ASSERT(pmic->read);
ASSERT(pmic->write);
dev = pmic;
dev->initialized = 1;
}
static int pm8921_masked_write(uint16_t addr,
uint8_t mask, uint8_t val)
{
int rc;
uint8_t reg;
rc = dev->read(&reg, 1, addr);
if (rc)
{
return rc;
}
reg &= ~mask;
reg |= val & mask;
rc = dev->write(&reg, 1, addr);
return rc;
}
/* Set the BOOT_DONE flag */
void pm8921_boot_done(void)
{
uint8_t val;
ASSERT(dev);
ASSERT(dev->initialized);
dev->read(&val, 1, PBL_ACCESS_2);
val |= PBL_ACCESS_2_ENUM_TIMER_STOP;
/* TODO: Remove next line when h/w is rewired for battery simulation.*/
val |= (0x7 << 2);
dev->write(&val, 1, PBL_ACCESS_2);
dev->read(&val, 1, SYS_CONFIG_2);
val |= (SYS_CONFIG_2_BOOT_DONE | SYS_CONFIG_2_ADAPTIVE_BOOT_DISABLE);
dev->write(&val, 1, SYS_CONFIG_2);
}
/* Configure PMIC GPIO */
int pm8921_gpio_config(int gpio, struct pm8921_gpio *param)
{
int ret;
uint8_t bank[6];
uint8_t output_buf_config;
uint8_t output_value;
static uint8_t dir_map[] = {
PM_GPIO_MODE_OFF,
PM_GPIO_MODE_OUTPUT,
PM_GPIO_MODE_INPUT,
PM_GPIO_MODE_BOTH,
};
if (param == NULL) {
dprintf (CRITICAL, "pm8291_gpio struct not defined\n");
return -1;
}
/* Select banks and configure the gpio */
bank[0] = PM_GPIO_WRITE |
((param->vin_sel << PM_GPIO_VIN_SHIFT) &
PM_GPIO_VIN_MASK) |
PM_GPIO_MODE_ENABLE;
/* bank1 */
if ((param->direction & PM_GPIO_DIR_OUT) && param->output_buffer)
output_buf_config = PM_GPIO_OUT_BUFFER_OPEN_DRAIN;
else
output_buf_config = 0;
if ((param->direction & PM_GPIO_DIR_OUT) && param->output_value)
output_value = 1;
else
output_value = 0;
bank[1] = PM_GPIO_WRITE |
((1 << PM_GPIO_BANK_SHIFT) & PM_GPIO_BANK_MASK) |
((dir_map[param->direction] << PM_GPIO_MODE_SHIFT)
& PM_GPIO_MODE_MASK) |
output_buf_config |
output_value;
bank[2] = PM_GPIO_WRITE |
((2 << PM_GPIO_BANK_SHIFT) & PM_GPIO_BANK_MASK) |
((param->pull << PM_GPIO_PULL_SHIFT) &
PM_GPIO_PULL_MASK);
bank[3] = PM_GPIO_WRITE |
((3 << PM_GPIO_BANK_SHIFT) & PM_GPIO_BANK_MASK) |
((param->out_strength << PM_GPIO_OUT_STRENGTH_SHIFT) &
PM_GPIO_OUT_STRENGTH_MASK) |
(param->disable_pin ? PM_GPIO_PIN_DISABLE : PM_GPIO_PIN_ENABLE);
bank[4] = PM_GPIO_WRITE |
((4 << PM_GPIO_BANK_SHIFT) & PM_GPIO_BANK_MASK) |
((param->function << PM_GPIO_FUNC_SHIFT) &
PM_GPIO_FUNC_MASK);
bank[5] = PM_GPIO_WRITE |
((5 << PM_GPIO_BANK_SHIFT) & PM_GPIO_BANK_MASK) |
(param->inv_int_pol ? 0 : PM_GPIO_NON_INT_POL_INV);
ret = dev->write(bank, 6, GPIO_CNTL(gpio));
if (ret) {
dprintf(CRITICAL, "Failed to write to PM8921 ret=%d.\n", ret);
return -1;
}
return 0;
}
int pm8921_ldo_set_voltage(uint32_t ldo_id, uint32_t voltage)
{
uint8_t mult;
uint8_t val = 0;
uint32_t ldo_number = (ldo_id & ~LDO_P_MASK);
int32_t ret = 0;
/* Find the voltage multiplying factor */
if(ldo_id & LDO_P_MASK)
mult = ldo_p_voltage_mult[voltage];
else
mult = ldo_n_voltage_mult[voltage];
/* Program the TEST reg */
if (ldo_id & LDO_P_MASK){
/* Bank 2, only for p ldo, use 1.25V reference */
val = 0x0;
val |= ( 1 << PM8921_LDO_TEST_REG_RW );
val |= ( 2 << PM8921_LDO_TEST_REG_BANK_SEL);
ret = dev->write(&val, 1, PM8921_LDO_TEST_REG(ldo_number));
if (ret) {
dprintf(CRITICAL, "Failed to write to PM8921 LDO Test Reg ret=%d.\n", ret);
return -1;
}
/* Bank 4, only for p ldo, disable output range ext, normal capacitance */
val = 0x0;
val |= ( 1 << PM8921_LDO_TEST_REG_RW );
val |= ( 4 << PM8921_LDO_TEST_REG_BANK_SEL);
ret = dev->write(&val, 1, PM8921_LDO_TEST_REG(ldo_number));
if (ret) {
dprintf(CRITICAL, "Failed to write to PM8921 LDO Test Reg ret=%d.\n", ret);
return -1;
}
}
/* Program the CTRL reg */
val = 0x0;
val |= ( 1 << PM8921_LDO_CTRL_REG_ENABLE);
val |= ( 1 << PM8921_LDO_CTRL_REG_PULL_DOWN);
val |= ( 0 << PM8921_LDO_CTRL_REG_POWER_MODE);
val |= ( mult << PM8921_LDO_CTRL_REG_VOLTAGE);
ret = dev->write(&val, 1, PM8921_LDO_CTRL_REG(ldo_number));
if (ret) {
dprintf(CRITICAL, "Failed to write to PM8921 LDO Ctrl Reg ret=%d.\n", ret);
return -1;
}
return 0;
}
/*
* Configure PMIC for reset and power off.
* reset = 1: Configure reset.
* reset = 0: Configure power off.
*/
int pm8921_config_reset_pwr_off(unsigned reset)
{
int rc;
/* Enable SMPL(Short Momentary Power Loss) if resetting is desired. */
rc = pm8921_masked_write(PM8921_SLEEP_CTRL_REG,
SLEEP_CTRL_SMPL_EN_MASK,
(reset ? SLEEP_CTRL_SMPL_EN_RESET : SLEEP_CTRL_SMPL_EN_PWR_OFF));
if (rc)
{
goto read_write_err;
}
/*
* Select action to perform (reset or shutdown) when PS_HOLD goes low.
* Also ensure that KPD, CBL0, and CBL1 pull ups are enabled and that
* USB charging is enabled.
*/
rc = pm8921_masked_write(PM8921_PON_CTRL_1_REG,
PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN
| PON_CTRL_1_WD_EN_MASK,
PON_CTRL_1_PULL_UP_MASK | PON_CTRL_1_USB_PWR_EN
| (reset ? PON_CTRL_1_WD_EN_RESET : PON_CTRL_1_WD_EN_PWR_OFF));
if (rc)
{
goto read_write_err;
}
read_write_err:
return rc;
}
+111
View File
@@ -0,0 +1,111 @@
/*
* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of Code Aurora Forum, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define PBL_ACCESS_2 0x005
#define PBL_ACCESS_2_ENUM_TIMER_STOP (1 << 1)
#define SYS_CONFIG_2 0x007
#define SYS_CONFIG_2_BOOT_DONE (1 << 6)
#define SYS_CONFIG_2_ADAPTIVE_BOOT_DISABLE (1 << 7)
#define PM8921_LDO_REG_BASE 0x0AE
#define PM8921_LDO_CTRL_REG(id) (PM8921_LDO_REG_BASE + (2 * (id-1)))
#define PM8921_LDO_TEST_REG(id) (PM8921_LDO_CTRL_REG(id) + 1)
/* Bit offsets LDO CTRL register */
#define PM8921_LDO_CTRL_REG_ENABLE 7
#define PM8921_LDO_CTRL_REG_PULL_DOWN 6
#define PM8921_LDO_CTRL_REG_POWER_MODE 5
#define PM8921_LDO_CTRL_REG_VOLTAGE 0
/* Bit offsets LDO Test register */
#define PM8921_LDO_TEST_REG_BANK_SEL 4
#define PM8921_LDO_TEST_REG_RW 7
#define PM8921_LDO_TEST_REG_BANK2_RANGE_SEL 2
#define PM8921_LDO_TEST_REG_BANK2_FINE_STEP 1
#define PM8921_LDO_TEST_REG_BANK4_RANGE_EXT 0
#define GPIO_CNTL_BASE 0x150
#define GPIO_CNTL(n) (GPIO_CNTL_BASE + n)
/* GPIO Bank register programming */
#define PM_GPIO_BANK_MASK 0x70
#define PM_GPIO_BANK_SHIFT 4
#define PM_GPIO_WRITE 0x80
/* Bank 0 */
#define PM_GPIO_VIN_MASK 0x0E
#define PM_GPIO_VIN_SHIFT 1
#define PM_GPIO_MODE_ENABLE 0x01
/* Bank 1 */
#define PM_GPIO_MODE_MASK 0x0C
#define PM_GPIO_MODE_SHIFT 2
#define PM_GPIO_OUT_BUFFER_OPEN_DRAIN 0x02
#define PM_GPIO_OUT_INVERT 0x01
#define PM_GPIO_MODE_OFF 3
#define PM_GPIO_MODE_OUTPUT 2
#define PM_GPIO_MODE_INPUT 0
#define PM_GPIO_MODE_BOTH 1
/* Bank 2 */
#define PM_GPIO_PULL_MASK 0x0E
#define PM_GPIO_PULL_SHIFT 1
/* Bank 3 */
#define PM_GPIO_OUT_STRENGTH_MASK 0x0C
#define PM_GPIO_OUT_STRENGTH_SHIFT 2
#define PM_GPIO_PIN_ENABLE 0x00
#define PM_GPIO_PIN_DISABLE 0x01
/* Bank 4 */
#define PM_GPIO_FUNC_MASK 0x0E
#define PM_GPIO_FUNC_SHIFT 1
/* Bank 5 */
#define PM_GPIO_NON_INT_POL_INV 0x08
/* PON CTRL 1 register */
#define PM8921_PON_CTRL_1_REG 0x01C
#define PON_CTRL_1_PULL_UP_MASK 0xE0
#define PON_CTRL_1_USB_PWR_EN 0x10
#define PON_CTRL_1_WD_EN_MASK 0x08
#define PON_CTRL_1_WD_EN_RESET 0x08
#define PON_CTRL_1_WD_EN_PWR_OFF 0x00
/* SLEEP CTRL register */
#define PM8921_SLEEP_CTRL_REG 0x10A
#define SLEEP_CTRL_SMPL_EN_MASK 0x04
#define SLEEP_CTRL_SMPL_EN_RESET 0x04
#define SLEEP_CTRL_SMPL_EN_PWR_OFF 0x00
+7
View File
@@ -0,0 +1,7 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include
OBJS += \
$(LOCAL_DIR)/pm8921.o
+36
View File
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __DEV_TWL4030_H
#define __DEV_TWL4030_H
#include <sys/types.h>
void twl4030_init(void);
/* USB parts of the pmic */
int twl4030_usb_reset(void);
int twl4030_set_usb_pullup(bool pullup);
int twl4030_init_hs(void);
#endif
+7
View File
@@ -0,0 +1,7 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include
OBJS += \
$(LOCAL_DIR)/twl4030.o
+169
View File
@@ -0,0 +1,169 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <debug.h>
#include <sys/types.h>
#include <dev/i2c.h>
#include <dev/twl4030.h>
#include "twl4030_hw.h"
// XXX move to target specific setup
#define TWL_I2C_BUS 0
void twl4030_init(void)
{
}
static int twl4030_usb_write(uint8_t address, uint8_t data)
{
return i2c_write_reg(TWL_I2C_BUS, TWL_USB_ADDR, address, data);
}
static int twl4030_usb_read(uint8_t address)
{
uint8_t data;
int err = i2c_read_reg(TWL_I2C_BUS, TWL_USB_ADDR, address, &data);
if (err < 0)
return err;
return data;
}
static int twl4030_usb_set_bits(uint8_t reg, uint8_t bits)
{
return twl4030_usb_write(reg + 1, bits);
}
static int twl4030_usb_clear_bits(uint8_t reg, uint8_t bits)
{
return twl4030_usb_write(reg + 2, bits);
}
static void twl4030_i2c_access(bool on)
{
int val;
if ((val = twl4030_usb_read(PHY_CLK_CTRL)) >= 0) {
if (on) {
/* enable DPLL to access PHY registers over I2C */
val |= REQ_PHY_DPLL_CLK;
twl4030_usb_write(PHY_CLK_CTRL, (uint8_t)val);
while (!(twl4030_usb_read(PHY_CLK_CTRL_STS) & PHY_DPLL_CLK)) {
spin(10);
}
if (!(twl4030_usb_read(PHY_CLK_CTRL_STS) & PHY_DPLL_CLK))
printf("Timeout setting T2 HSUSB " "PHY DPLL clock\n");
} else {
/* let ULPI control the DPLL clock */
val &= ~REQ_PHY_DPLL_CLK;
twl4030_usb_write(PHY_CLK_CTRL, (uint8_t)val);
}
}
return;
}
int twl4030_usb_reset(void)
{
TRACE_ENTRY;
#if 0
twl4030_usb_clear_bits(OTG_CTRL, DMPULLDOWN | DPPULLDOWN);
twl4030_usb_clear_bits(USB_INT_EN_RISE, ~0);
twl4030_usb_clear_bits(USB_INT_EN_FALL, ~0);
twl4030_usb_clear_bits(MCPC_IO_CTRL, ~TXDTYP);
twl4030_usb_set_bits(MCPC_IO_CTRL, TXDTYP);
twl4030_usb_clear_bits(OTHER_FUNC_CTRL, (BDIS_ACON_EN | FIVEWIRE_MODE));
twl4030_usb_clear_bits(OTHER_IFC_CTRL, ~0);
twl4030_usb_clear_bits(OTHER_INT_EN_RISE, ~0);
twl4030_usb_clear_bits(OTHER_INT_EN_FALL, ~0);
twl4030_usb_clear_bits(OTHER_IFC_CTRL2, ~0);
twl4030_usb_clear_bits(REG_CTRL_EN, ULPI_I2C_CONFLICT_INTEN);
twl4030_usb_clear_bits(OTHER_FUNC_CTRL2, VBAT_TIMER_EN);
#endif
/* Enable writing to power configuration registers */
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, PROTECT_KEY, 0xC0);
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, PROTECT_KEY, 0x0C);
/* put VUSB3V1 LDO in active state */
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB_DEDICATED2, 0);
/* input to VUSB3V1 LDO is from VBAT, not VBUS */
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB_DEDICATED1, 0x14);
/* turn on 3.1V regulator */
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB3V1_DEV_GRP, 0x20);
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB3V1_TYPE, 0);
/* turn on 1.5V regulator */
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V5_DEV_GRP, 0x20);
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V5_TYPE, 0);
/* turn on 1.8V regulator */
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V8_DEV_GRP, 0x20);
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, VUSB1V8_TYPE, 0);
/* disable access to power configuration registers */
i2c_write_reg(TWL_I2C_BUS, TWL_PM_RECEIVER_ADDR, PROTECT_KEY, 0);
/* turn on the phy */
uint8_t pwr = twl4030_usb_read(PHY_PWR_CTRL);
pwr &= ~PHYPWD;
twl4030_usb_write(PHY_PWR_CTRL, pwr);
twl4030_usb_write(PHY_CLK_CTRL,
twl4030_usb_read(PHY_CLK_CTRL) |
(CLOCKGATING_EN | CLK32K_EN));
/* set DPLL i2c access mode */
twl4030_i2c_access(true);
/* set ulpi mode */
twl4030_usb_clear_bits(IFC_CTRL, CARKITMODE);
twl4030_usb_set_bits(POWER_CTRL, OTG_ENAB);
twl4030_usb_write(FUNC_CTRL, XCVRSELECT_HS); // set high speed mode
// twl4030_usb_write(FUNC_CTRL, XCVRSELECT_FS); // set full speed mode
twl4030_i2c_access(false);
return 0;
}
int twl4030_init_hs(void)
{
return 0;
}
int twl4030_set_usb_pullup(bool pullup)
{
TRACE_ENTRY;
if (pullup) {
twl4030_usb_clear_bits(OTG_CTRL, DPPULLDOWN);
twl4030_usb_set_bits(FUNC_CTRL, TERMSELECT);
} else {
twl4030_usb_clear_bits(FUNC_CTRL, TERMSELECT);
twl4030_usb_set_bits(OTG_CTRL, DPPULLDOWN);
}
return 0;
}
+369
View File
@@ -0,0 +1,369 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __TWL4030_HW_H
#define __TWL4030_HW_H
/* TWL i2c addresses */
#define TWL_I2C_ADDR0 0x48
#define TWL_I2C_ADDR1 0x49
#define TWL_I2C_ADDR2 0x4a
#define TWL_I2C_ADDR3 0x4b
#define TWL_USB_ADDR TWL_I2C_ADDR0
#define TWL_INTBR_ADDR TWL_I2C_ADDR1
#define TWL_PM_RECEIVER_ADDR TWL_I2C_ADDR3
/* TWL registers */
#define PROTECT_KEY 0x44
#define VAUX1_DEV_GRP 0x72
#define VAUX1_TYPE 0x73
#define VAUX1_REMAP 0x74
#define VAUX1_DEDICATED 0x75
#define VAUX2_DEV_GRP 0x76
#define VAUX2_TYPE 0x77
#define VAUX2_REMAP 0x78
#define VAUX2_DEDICATED 0x79
#define VAUX3_DEV_GRP 0x7a
#define VAUX3_TYPE 0x7b
#define VAUX3_REMAP 0x7c
#define VAUX3_DEDICATED 0x7d
#define VAUX4_DEV_GRP 0x7e
#define VAUX4_TYPE 0x7f
#define VAUX4_REMAP 0x80
#define VAUX4_DEDICATED 0x81
#define VMMC1_DEV_GRP 0x82
#define VMMC1_TYPE 0x83
#define VMMC1_REMAP 0x84
#define VMMC1_DEDICATED 0x85
#define VMMC2_DEV_GRP 0x86
#define VMMC2_TYPE 0x87
#define VMMC2_REMAP 0x88
#define VMMC2_DEDICATED 0x89
#define VPLL1_DEV_GRP 0x8a
#define VPLL1_TYPE 0x8b
#define VPLL1_REMAP 0x8c
#define VPLL1_DEDICATED 0x8d
#define VPLL2_DEV_GRP 0x8e
#define VPLL2_TYPE 0x8f
#define VPLL2_REMAP 0x90
#define VPLL2_DEDICATED 0x91
#define VDAC_DEV_GRP 0x96
#define VDAC_DEDICATED 0x99
#define VDD2_DEV_GRP 0xBE
#define VDD2_TYPE 0xBF
#define VDD2_REMAP 0xC0
#define VDD2_CFG 0xC1
#define VSIM_DEV_GRP 0x92
#define VSIM_TYPE 0x93
#define VSIM_REMAP 0x94
#define VSIM_DEDICATED 0x95
#define PMBR1 0x92
#define SECONDS_REG 0x1C
#define MINUTES_REG 0x1D
#define ALARM_SECONDS_REG 0x23
#define ALARM_MINUTES_REG 0x24
#define ALARM_HOURS_REG 0x25
#define RTC_STATUS_REG 0x2A
#define RTC_INTERRUPTS_REG 0x2B
#define PWR_ISR1 0x2E
#define PWR_IMR1 0x2F
#define PWR_ISR2 0x30
#define PWR_IMR2 0x31
#define PWR_EDR1 0x33
#define CFG_PWRANA2 0x3F
#define RTC_INTERRUPTS_REG 0x2B
#define STS_HW_CONDITIONS 0x45
#define P1_SW_EVENTS 0x46
#define P2_SW_EVENTS 0x47
#define P3_SW_EVENTS 0x48
#define VDD1_TRIM1 0x62
#define VDD1_TRIM2 0x63
#define VDD1_VFLOOR 0xBB
#define VDD1_VROOF 0xBC
#define PB_CFG 0x4A
#define PB_WORD_MSB 0x4B
#define PB_WORD_LSB 0x4C
#define VSIM_REMAP 0x94
#define VDAC_REMAP 0x98
#define VINTANA1_DEV_GRP 0x9A
#define VINTANA1_REMAP 0x9C
#define VINTANA2_REMAP 0xA0
#define VINTANA2_DEV_GRP 0x9E
#define VINTDIG_DEV_GRP 0xA2
#define VINTDIG_REMAP 0xA4
#define VIO_DEV_GRP 0xA6
#define VIO_REMAP 0xA8
#define VDD1_REMAP 0xB2
#define VDD2_REMAP 0xC0
#define REGEN_REMAP 0xDC
#define NRESPWRON_REMAP 0xDF
#define CLKEN_REMAP 0xE2
#define SYSEN_REMAP 0xE5
#define HFCLKOUT_REMAP 0xE8
#define HFCLKOUT_DEV_GRP 0xE6
#define T32KCLKOUT_REMAP 0xEB
#define TRITON_RESET_REMAP 0xEE
#define MAINREF_REMAP 0xF1
#define VIBRA_CTL 0x45
#define VUSB1V5_DEV_GRP 0xCC
#define VUSB1V5_TYPE 0xCD
#define VUSB1V5_REMAP 0xCE
#define VUSB1V8_DEV_GRP 0xCF
#define VUSB1V8_TYPE 0xD0
#define VUSB1V8_REMAP 0xD1
#define VUSB3V1_DEV_GRP 0xD2
#define VUSB3V1_TYPE 0xD3
#define VUSB3V1_REMAP 0xD4
#define VUSBCP_DEV_GRP 0xD5
#define VUSBCP_TYPE 0xD6
#define VUSBCP_REMAP 0xD7
#define VUSB_DEDICATED1 0xD8
#define VUSB_DEDICATED2 0xD9
/* USB registers */
#define VENDOR_ID_LO 0x0
#define VENDOR_ID_HI 0x1
#define PRODUCT_ID_LO 0x2
#define PRODUCT_ID_HI 0x3
#define FUNC_CTRL 0x4
#define FUNC_CTRL_SET 0x5
#define FUNC_CTRL_CLR 0x6
# define SUSPENDM (1 << 6)
# define RESET (1 << 5)
# define OPMODE_MASK (3 << 3) /* bits 3 and 4 */
# define OPMODE_NORMAL (0 << 3)
# define OPMODE_NONDRIVING (1 << 3)
# define OPMODE_DISABLE_BIT_NRZI (2 << 3)
# define TERMSELECT (1 << 2)
# define XCVRSELECT_MASK (3 << 0) /* bits 0 and 1 */
# define XCVRSELECT_HS (0 << 0)
# define XCVRSELECT_FS (1 << 0)
# define XCVRSELECT_LS (2 << 0)
# define XCVRSELECT_FS4LS (3 << 0)
#define IFC_CTRL 0x7
#define IFC_CTRL_SET 0x8
#define IFC_CTRL_CLR 0x9
# define INTERFACE_PROTECT_DISABLE (1 << 7)
# define AUTORESUME (1 << 4)
# define CLOCKSUSPENDM (1 << 3)
# define CARKITMODE (1 << 2)
# define FSLSSERIALMODE_3PIN (1 << 1)
#define OTG_CTRL 0xa
#define OTG_CTRL_SET 0xb
#define OTG_CTRL_CLR 0xc
#define DRVVBUS (1 << 5)
#define CHRGVBUS (1 << 4)
#define DISCHRGVBUS (1 << 3)
#define DMPULLDOWN (1 << 2)
#define DPPULLDOWN (1 << 1)
#define IDPULLUP (1 << 0)
#define USB_INT_EN_RISE 0xd
#define USB_INT_EN_RISE_SET 0xe
#define USB_INT_EN_RISE_CLR 0xf
#define USB_INT_EN_FALL 0x10
#define USB_INT_EN_FALL_SET 0x11
#define USB_INT_EN_FALL_CLR 0x12
# define HOSTDISCONNECT (1 << 0)
#define USB_INT_STS 0x13
#define USB_INT_LATCH 0x14
#define USB_DEBUG 0x15
#define SCRATCH_REG 0x16
#define SCRATCH_REG_SET 0x17
#define SCRATCH_REG_CLR 0x18
#define CARKIT_CTRL 0x19
#define CARKIT_CTRL_SET 0x1a
#define CARKIT_CTRL_CLR 0x1b
#define MICEN (1 << 6)
#define SPKRIGHTEN (1 << 5)
#define SPKLEFTEN (1 << 4)
#define RXDEN (1 << 3)
#define TXDEN (1 << 2)
#define IDGNDDRV (1 << 1)
#define CARKITPWR (1 << 0)
#define CARKIT_INT_DELAY 0x1c
#define CARKIT_INT_EN 0x1d
#define CARKIT_INT_EN_SET 0x1e
#define CARKIT_INT_EN_CLR 0x1f
#define CARKIT_INT_STS 0x20
#define CARKIT_INT_LATCH 0x21
#define CARKIT_PLS_CTRL 0x22
#define CARKIT_PLS_CTRL_SET 0x23
#define CARKIT_PLS_CTRL_CLR 0x24
# define SPKRRIGHT_BIASEN (1 << 3)
# define SPKRLEFT_BIASEN (1 << 2)
# define RXPLSEN (1 << 1)
# define TXPLSEN (1 << 0)
#define TRANS_POS_WIDTH 0x25
#define TRANS_NEG_WIDTH 0x26
#define RCV_PLTY_RECOVERY 0x27
#define MCPC_CTRL 0x30
#define MCPC_CTRL_SET 0x31
#define MCPC_CTRL_CLR 0x32
#define RTSOL (1 << 7)
#define EXTSWR (1 << 6)
#define EXTSWC (1 << 5)
#define VOICESW (1 << 4)
#define OUT64K (1 << 3)
#define RTSCTSSW (1 << 2)
#define HS_UART (1 << 0)
#define MCPC_IO_CTRL 0x033
#define MCPC_IO_CTRL_SET 0x034
#define MCPC_IO_CTRL_CLR 0x035
#define MICBIASEN (1<< 5)
#define CTS_NPU (1 << 4)
#define RXD_PU (1 << 3)
#define TXDTYP (1 << 2)
#define CTSTYP (1 << 1)
#define RTSTYP (1 << 0)
#define MCPC_CTRL2 0x036
#define MCPC_CTRL2_SET 0x037
#define MCPC_CTRL2_CLR 0x038
# define MCPC_CK_EN (1 << 0)
#define OTHER_FUNC_CTRL 0x080
#define OTHER_FUNC_CTRL_SET 0x081
#define OTHER_FUNC_CTRL_CLR 0x082
#define BDIS_ACON_EN (1<< 4)
#define FIVEWIRE_MODE (1 << 2)
#define OTHER_IFC_CTRL 0x083
#define OTHER_IFC_CTRL_SET 0x084
#define OTHER_IFC_CTRL_CLR 0x085
# define OE_INT_EN (1 << 6)
# define CEA2011_MODE (1 << 5)
# define FSLSSERIALMODE_4PIN (1 << 4)
# define HIZ_ULPI_60MHZ_OUT (1 << 3)
# define HIZ_ULPI (1 << 2)
# define ALT_INT_REROUTE (1 << 0)
#define OTHER_INT_EN_RISE 0x086
#define OTHER_INT_EN_RISE_SET 0x087
#define OTHER_INT_EN_RISE_CLR 0x088
#define OTHER_INT_EN_FALL 0x089
#define OTHER_INT_EN_FALL_SET 0x08A
#define OTHER_INT_EN_FALL_CLR 0x08B
#define OTHER_INT_STS 0x8C
#define OTHER_INT_LATCH 0x8D
#define ID_INT_EN_RISE 0x08E
#define ID_INT_EN_RISE_SET 0x08F
#define ID_INT_EN_RISE_CLR 0x090
#define ID_INT_EN_FALL 0x091
#define ID_INT_EN_FALL_SET 0x092
#define ID_INT_EN_FALL_CLR 0x093
#define ID_INT_STS 0x094
#define ID_INT_LATCH 0x95
#define ID_STATUS 0x96
#define CARKIT_SM_1_INT_EN 0x097
#define CARKIT_SM_1_INT_EN_SET 0x098
#define CARKIT_SM_1_INT_EN_CLR 0x099
#define CARKIT_SM_1_INT_STS 0x09A
#define CARKIT_SM_1_INT_LATCH 0x9B
#define CARKIT_SM_2_INT_EN 0x09C
#define CARKIT_SM_2_INT_EN_SET 0x09D
#define CARKIT_SM_2_INT_EN_CLR 0x09E
#define CARKIT_SM_2_INT_STS 0x09F
#define CARKIT_SM_2_INT_LATCH 0xA0
#define CARKIT_SM_CTRL 0x0A1
#define CARKIT_SM_CTRL_SET 0x0A2
#define CARKIT_SM_CTRL_CLR 0x0A3
#define CARKIT_SM_CMD 0x0A4
#define CARKIT_SM_CMD_SET 0x0A5
#define CARKIT_SM_CMD_CLR 0x0A6
#define CARKIT_SM_CMD_STS 0xA7
#define CARKIT_SM_STATUS 0xA8
#define CARKIT_SM_NEXT_STATUS 0xA9
#define CARKIT_SM_ERR_STATUS 0xAA
#define CARKIT_SM_CTRL_STATE 0xAB
#define POWER_CTRL 0xAC
#define POWER_CTRL_SET 0xAD
#define POWER_CTRL_CLR 0xAE
# define OTG_ENAB (1 << 5)
#define OTHER_IFC_CTRL2 0xAF
#define OTHER_IFC_CTRL2_SET 0xB0
#define OTHER_IFC_CTRL2_CLR 0xB1
# define ULPI_TXEN_POL (1 << 3)
# define ULPI_4PIN_2430 (1 << 2)
#define REG_CTRL_EN 0xB2
#define REG_CTRL_EN_SET 0xB3
#define REG_CTRL_EN_CLR 0xB4
#define REG_CTRL_ERROR 0xB5
#define ULPI_I2C_CONFLICT_INTEN (1 << 0)
#define OTHER_FUNC_CTRL2 0xB8
#define OTHER_FUNC_CTRL2_SET 0xB9
#define OTHER_FUNC_CTRL2_CLR 0xBA
#define VBAT_TIMER_EN (1 << 0)
#define CARKIT_ANA_CTRL 0xBB
#define CARKIT_ANA_CTRL_SET 0xBC
#define CARKIT_ANA_CTRL_CLR 0xBD
#define VBUS_DEBOUNCE 0xC0
#define ID_DEBOUNCE 0xC1
#define TPH_DP_CON_MIN 0xC2
#define TPH_DP_CON_MAX 0xC3
#define TCR_DP_CON_MIN 0xC4
#define TCR_DP_CON_MAX 0xC5
#define TPH_DP_PD_SHORT 0xC6
#define TPH_CMD_DLY 0xC7
#define TPH_DET_RST 0xC8
#define TPH_AUD_BIAS 0xC9
#define TCR_UART_DET_MIN 0xCA
#define TCR_UART_DET_MAX 0xCB
#define TPH_ID_INT_PW 0xCD
#define TACC_ID_INT_WAIT 0xCE
#define TACC_ID_INT_PW 0xCF
#define TPH_CMD_WAIT 0xD0
#define TPH_ACK_WAIT 0xD1
#define TPH_DP_DISC_DET 0xD2
#define VBAT_TIMER 0xD3
#define CARKIT_4W_DEBUG 0xE0
#define CARKIT_5W_DEBUG 0xE1
#define CARKIT_5W_DEBUG 0xE1
#define TEST_CTRL_CLR 0xEB
#define TEST_CARKIT_SET 0xEC
#define TEST_CARKIT_CLR 0xED
#define TEST_POWER_SET 0xEE
#define TEST_POWER_CLR 0xEF
#define TEST_ULPI 0xF0
#define TXVR_EN_TEST_SET 0xF2
#define TXVR_EN_TEST_CLR 0xF3
#define VBUS_EN_TEST 0xF4
#define ID_EN_TEST 0xF5
#define PSM_EN_TEST_SET 0xF6
#define PSM_EN_TEST_CLR 0xF7
#define PHY_TRIM_CTRL 0xFC
#define PHY_PWR_CTRL 0xFD
# define PHYPWD (1 << 0)
#define PHY_CLK_CTRL 0xFE
# define CLOCKGATING_EN (1 << 2)
# define CLK32K_EN (1 << 1)
# define REQ_PHY_DPLL_CLK (1 << 0)
#define PHY_CLK_CTRL_STS 0xFF
# define PHY_DPLL_CLK (1 << 0)
#endif
+5
View File
@@ -0,0 +1,5 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
OBJS += \
$(LOCAL_DIR)/dev.o
+139
View File
@@ -0,0 +1,139 @@
/*
* Copyright (c) 2008, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __DEV_SSBI_H
#define __DEV_SSBI_H
//Macros for SSBI Qwerty keypad for 7x30
/* SSBI 2.0 controller registers */
#define MSM_SSBI_BASE 0xAD900000
#define SSBI_TIMEOUT_US 100
#define SSBI2_CTL 0x0000
#define SSBI2_RESET 0x0004
#define SSBI2_CMD 0x0008
#define SSBI2_RD 0x0010
#define SSBI2_STATUS 0x0014
#define SSBI2_PRIORITIES 0x0018
#define SSBI2_MODE2 0x001C
/* SSBI_CMD fields */
#define SSBI_CMD_SEND_TERM_SYM (0x01 << 27)
#define SSBI_CMD_WAKEUP_SLAVE (0x01 << 26)
#define SSBI_CMD_USE_ENABLE (0x01 << 25)
#define SSBI_CMD_RDWRN (0x01 << 24)
#define SSBI_CMD_REG_ADDR_SHFT (0x10)
#define SSBI_CMD_REG_ADDR_MASK (0xFF << SSBI_CMD_REG_ADDR_SHFT)
#define SSBI_CMD_REG_DATA_SHFT (0x00)
#define SSBI_CMD_REG_DATA_MASK (0xFF << SSBI_CMD_REG_DATA_SHFT)
/* SSBI_STATUS fields */
#define SSBI_STATUS_DATA_IN 0x10
#define SSBI_STATUS_RD_CLOBBERED 0x08
#define SSBI_STATUS_RD_READY 0x04
#define SSBI_STATUS_READY 0x02
#define SSBI_STATUS_MCHN_BUSY 0x01
/* SSBI_RD fields */
#define SSBI_RD_USE_ENABLE 0x02000000
#define SSBI_RD_RDWRN 0x01000000
#define SSBI_RD_REG_ADDR_SHFT 0x10
#define SSBI_RD_REG_ADDR_MASK (0xFF << SSBI_RD_REG_ADDR_SHFT)
#define SSBI_RD_REG_DATA_SHFT (0x00)
#define SSBI_RD_REG_DATA_MASK (0xFF << SSBI_RD_REG_DATA_SHFT)
/* SSBI_MODE2 fields */
#define SSBI_MODE2_REG_ADDR_15_8_SHFT 0x04
#define SSBI_MODE2_REG_ADDR_15_8_MASK (0x7F << SSBI_MODE2_REG_ADDR_15_8_SHFT)
#define SSBI_MODE2_ADDR_WIDTH_SHFT 0x01
#define SSBI_MODE2_ADDR_WIDTH_MASK (0x07 << SSBI_MODE2_ADDR_WIDTH_SHFT)
#define SSBI_MODE2_SSBI2_MODE 0x00000001
//Keypad controller configurations
#define SSBI_REG_KYPD_CNTL_ADDR 0x148
#define SSBI_REG_KYPD_SCAN_ADDR 0x149
#define SSBI_REG_KYPD_TEST_ADDR 0x14A
#define SSBI_REG_KYPD_REC_DATA_ADDR 0x14B
#define SSBI_REG_KYPD_OLD_DATA_ADDR 0x14C
/* PMIC Arbiter 1: SSBI2 Configuration Micro ARM registers */
#define PA1_SSBI2_CMD 0x00500000
#define PA1_SSBI2_RD_STATUS 0x00500004
#define PA1_SSBI2_REG_ADDR_SHIFT 8
#define PA1_SSBI2_CMD_RDWRN_SHIFT 24
#define PA1_SSBI2_TRANS_DONE_SHIFT 27
#define PA1_SSBI2_REG_DATA_MASK 0xFF
#define PA1_SSBI2_REG_DATA_SHIFT 0
#define PA1_SSBI2_CMD_READ 1
#define PA1_SSBI2_CMD_WRITE 0
/* PMIC Arbiter 2: SSBI2 Configuration Micro ARM registers */
#define PA2_SSBI2_CMD 0x00C00000
#define PA2_SSBI2_RD_STATUS 0x00C00004
#define PA2_SSBI2_REG_ADDR_SHIFT 8
#define PA2_SSBI2_CMD_RDWRN_SHIFT 24
#define PA2_SSBI2_TRANS_DONE_SHIFT 27
#define PA2_SSBI2_REG_DATA_MASK 0xFF
#define PA2_SSBI2_REG_DATA_SHIFT 0
#define PA2_SSBI2_CMD_READ 1
#define PA2_SSBI2_CMD_WRITE 0
#define SSBI_CMD_READ(AD) \
(SSBI_CMD_RDWRN | (((AD) & 0xFF) << SSBI_CMD_REG_ADDR_SHFT))
#define SSBI_CMD_WRITE(AD, DT) \
((((AD) & 0xFF) << SSBI_CMD_REG_ADDR_SHFT) | \
(((DT) & 0xFF) << SSBI_CMD_REG_DATA_SHFT))
#define SSBI_MODE2_REG_ADDR_15_8(MD, AD) \
(((MD) & 0x0F) | ((((AD) >> 8) << SSBI_MODE2_REG_ADDR_15_8_SHFT) & \
SSBI_MODE2_REG_ADDR_15_8_MASK))
int i2c_ssbi_read_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr);
int i2c_ssbi_write_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr);
int pa1_ssbi2_read_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr);
int pa1_ssbi2_write_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr);
#endif
+6
View File
@@ -0,0 +1,6 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include
OBJS += \
$(LOCAL_DIR)/ssbi.o
+251
View File
@@ -0,0 +1,251 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google, Inc. nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <debug.h>
#include <reg.h>
#include <sys/types.h>
#include <dev/ssbi.h>
int i2c_ssbi_poll_for_device_ready(void)
{
unsigned long timeout = SSBI_TIMEOUT_US;
while (!(readl(MSM_SSBI_BASE + SSBI2_STATUS) & SSBI_STATUS_READY)) {
if (--timeout == 0) {
dprintf(INFO, "In Device ready function:Timeout, status %x\n", readl(MSM_SSBI_BASE + SSBI2_STATUS));
return 1;
}
}
return 0;
}
int i2c_ssbi_poll_for_read_completed(void)
{
unsigned long timeout = SSBI_TIMEOUT_US;
while (!(readl(MSM_SSBI_BASE + SSBI2_STATUS) & SSBI_STATUS_RD_READY)) {
if (--timeout == 0) {
dprintf(INFO, "In read completed function:Timeout, status %x\n", readl(MSM_SSBI_BASE + SSBI2_STATUS));
return 1;
}
}
return 0;
}
int i2c_ssbi_read_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr)
{
int ret = 0;
unsigned char *buf = buffer;
unsigned short len = length;
unsigned short addr = slave_addr;
unsigned long read_cmd = SSBI_CMD_READ(addr);
unsigned long mode2 = readl(MSM_SSBI_BASE + SSBI2_MODE2);
//buf = alloc(len * sizeof(8));
if (mode2 & SSBI_MODE2_SSBI2_MODE)
writel(SSBI_MODE2_REG_ADDR_15_8(mode2, addr),
MSM_SSBI_BASE + SSBI2_MODE2);
while (len) {
ret = i2c_ssbi_poll_for_device_ready();
if (ret) {
dprintf (CRITICAL, "Error: device not ready\n");
return ret;
}
writel(read_cmd, MSM_SSBI_BASE + SSBI2_CMD);
ret = i2c_ssbi_poll_for_read_completed();
if (ret) {
dprintf (CRITICAL, "Error: read not completed\n");
return ret;
}
*buf++ = readl(MSM_SSBI_BASE + SSBI2_RD) & SSBI_RD_REG_DATA_MASK;
len--;
}
return 0;
}
int i2c_ssbi_write_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr)
{
int ret = 0;
unsigned long timeout = SSBI_TIMEOUT_US;
unsigned char *buf = buffer;
unsigned short len = length;
unsigned short addr = slave_addr;
unsigned long mode2 = readl(MSM_SSBI_BASE + SSBI2_MODE2);
if (mode2 & SSBI_MODE2_SSBI2_MODE)
writel(SSBI_MODE2_REG_ADDR_15_8(mode2, addr),
MSM_SSBI_BASE + SSBI2_MODE2);
while (len) {
ret = i2c_ssbi_poll_for_device_ready();
if (ret) {
dprintf (CRITICAL, "Error: device not ready\n");
return ret;
}
writel(SSBI_CMD_WRITE(addr, *buf++), MSM_SSBI_BASE + SSBI2_CMD);
while (readl(MSM_SSBI_BASE + SSBI2_STATUS) & SSBI_STATUS_MCHN_BUSY) {
if (--timeout == 0) {
dprintf(INFO, "In Device ready function:Timeout, status %x\n", readl(MSM_SSBI_BASE + SSBI2_STATUS));
return 1;
}
}
len--;
}
return 0;
}
int pa1_ssbi2_read_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr)
{
unsigned val = 0x0;
unsigned temp = 0x0000;
unsigned char *buf = buffer;
unsigned short len = length;
unsigned short addr = slave_addr;
unsigned long timeout = SSBI_TIMEOUT_US;
while(len)
{
val |= ((addr << PA1_SSBI2_REG_ADDR_SHIFT) |
(PA1_SSBI2_CMD_READ << PA1_SSBI2_CMD_RDWRN_SHIFT));
writel(val, PA1_SSBI2_CMD);
while(!((temp = readl(PA1_SSBI2_RD_STATUS)) & (1 << PA1_SSBI2_TRANS_DONE_SHIFT))) {
if (--timeout == 0) {
dprintf(INFO, "In Device ready function:Timeout\n");
return 1;
}
}
len--;
*buf++ = (temp & (PA1_SSBI2_REG_DATA_MASK << PA1_SSBI2_REG_DATA_SHIFT));
}
return 0;
}
int pa1_ssbi2_write_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr)
{
unsigned val;
unsigned char *buf = buffer;
unsigned short len = length;
unsigned short addr = slave_addr;
unsigned temp = 0x00;
unsigned char written_data1 = 0x00;
unsigned long timeout = SSBI_TIMEOUT_US;
//unsigned char written_data2 = 0x00;
while(len)
{
temp = 0x00;
written_data1 = 0x00;
val = (addr << PA1_SSBI2_REG_ADDR_SHIFT) |
(PA1_SSBI2_CMD_WRITE << PA1_SSBI2_CMD_RDWRN_SHIFT) |
(*buf & 0xFF);
writel(val, PA1_SSBI2_CMD);
while(!((temp = readl(PA1_SSBI2_RD_STATUS)) & (1 << PA1_SSBI2_TRANS_DONE_SHIFT))) {
if (--timeout == 0) {
dprintf(INFO, "In Device write function:Timeout\n");
return 1;
}
}
len--;
buf++;
}
return 0;
}
int pa2_ssbi2_read_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr)
{
unsigned val = 0x0;
unsigned temp = 0x0000;
unsigned char *buf = buffer;
unsigned short len = length;
unsigned short addr = slave_addr;
unsigned long timeout = SSBI_TIMEOUT_US;
while(len)
{
val |= ((addr << PA2_SSBI2_REG_ADDR_SHIFT) |
(PA2_SSBI2_CMD_READ << PA2_SSBI2_CMD_RDWRN_SHIFT));
writel(val, PA2_SSBI2_CMD);
while(!((temp = readl(PA2_SSBI2_RD_STATUS)) & (1 << PA2_SSBI2_TRANS_DONE_SHIFT))) {
if (--timeout == 0) {
dprintf(INFO, "In Device ready function:Timeout\n");
return 1;
}
}
len--;
*buf++ = (temp & (PA2_SSBI2_REG_DATA_MASK << PA2_SSBI2_REG_DATA_SHIFT));
}
return 0;
}
int pa2_ssbi2_write_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr)
{
unsigned val;
unsigned char *buf = buffer;
unsigned short len = length;
unsigned short addr = slave_addr;
unsigned temp = 0x00;
unsigned char written_data1 = 0x00;
unsigned long timeout = SSBI_TIMEOUT_US;
while(len)
{
temp = 0x00;
written_data1 = 0x00;
val = (addr << PA2_SSBI2_REG_ADDR_SHIFT) |
(PA2_SSBI2_CMD_WRITE << PA2_SSBI2_CMD_RDWRN_SHIFT) |
(*buf & 0xFF);
writel(val, PA2_SSBI2_CMD);
while(!((temp = readl(PA2_SSBI2_RD_STATUS)) & (1 << PA2_SSBI2_TRANS_DONE_SHIFT))) {
if (--timeout == 0) {
dprintf(INFO, "In Device write function:Timeout\n");
return 1;
}
}
len--;
buf++;
}
return 0;
}
Loaded 100 of 1813 files, more files were not shown because too many files have changed in this diff. Show more