bootcount.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright 2011 Calxeda, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 2 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <common.h>
  18. #include <asm/io.h>
  19. #ifdef CONFIG_BOOTCOUNT_LIMIT
  20. void bootcount_store(ulong a)
  21. {
  22. writel((BOOTCOUNT_MAGIC & 0xffff0000) | a, CONFIG_SYS_BOOTCOUNT_ADDR);
  23. }
  24. ulong bootcount_load(void)
  25. {
  26. u32 tmp = readl(CONFIG_SYS_BOOTCOUNT_ADDR);
  27. if ((tmp & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
  28. return 0;
  29. else
  30. return tmp & 0x0000ffff;
  31. }
  32. #endif