• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The Android Open Source Project
2 //
3 // This software is licensed under the terms of the GNU General Public
4 // License version 2, as published by the Free Software Foundation, and
5 // may be copied, distributed, and modified under those terms.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 // GNU General Public License for more details.
11 
12 #ifndef ANDROID_KERNEL_KERNEL_UTILS_H
13 #define ANDROID_KERNEL_KERNEL_UTILS_H
14 
15 #include "android/utils/compiler.h"
16 #include <stdint.h>
17 
18 ANDROID_BEGIN_HEADER
19 
20 // An enum used to list of the types of Linux kernel images we need to
21 // handle. Unfortunately, this affects how we setup the kernel command-line
22 // when launching the system.
23 //
24 // KERNEL_TYPE_LEGACY is any Linux kernel image before 3.10
25 // KERNEL_TYPE_3_10_OR_ABOVE is anything at 3.10 or above.
26 typedef enum {
27     KERNEL_TYPE_LEGACY = 0,
28     KERNEL_TYPE_3_10_OR_ABOVE = 1,
29 } KernelType;
30 
31 // Probe the kernel image at |kernelPath| and returns the corresponding
32 // KernelType value. On success, returns true and sets |*ktype| appropriately.
33 // On failure (e.g. if the file doesn't exist or cannot be probed), return
34 // false and doesn't touch |*ktype|.
35 bool android_pathProbeKernelType(const char* kernelPath, KernelType *ktype);
36 
37 // Return the serial device name prefix matching a given kernel type |ktype|.
38 // I.e. this should be "/dev/ttyS" for KERNEL_TYPE_LEGACY, and
39 // "/dev/ttyGF" for KERNEL_TYPE_3_10_OR_ABOVE.
40 const char* android_kernelSerialDevicePrefix(KernelType ktype);
41 
42 ANDROID_END_HEADER
43 
44 #endif  // ANDROID_KERNEL_KERNEL_UTILS_H
45